希望你們一切安好。如果EditText字段小於或等於13.5且大於33.0,則隱藏一個按鈕 - Java Android
如果我的EditText中的測試讀數在我的Android應用程序窗口中低於或等於13.5或大於33,我想隱藏一個按鈕(btnAppointment)。如果我的EditText字段輸入值介於13.60和32.99之間,Button(btnAppointment)應該只出現在屏幕上。如果超出這些參數,則不會在屏幕上顯示。
我想知道是否與button.setEnabled(false);
IF語句將做的伎倆,如果是這樣,我需要輸入到我的代碼。無論是protected void onCreate(Bundle savedInstanceState)
或創建我自己的public void appointmentTeacherOnClick
?
下面我插入了我的代碼,用於計算和顯示我的輸入測試字段提示。
public void calculateTest(View v){
String status;
test = Double.parseDouble(edtData.getText().toString());
String result = String.format("%.2f", test);
Log.d("MyActivity", result);
if(test < 9.5) {
status = "Normal - Well Done =)";
} else if (test >= 9.5 && test < 13.5){
status = "Caution - Keep on Track =|";
} else if (test >= 13.5 && test < 33.0) {
status ="Action Needed =(";
} else {
status = "Normal Results are between 0 - 33";
}
AlertDialog alertDialog = new AlertDialog.Builder(this).create();
alertDialog.setTitle("Result Feedback...");
alertDialog.setMessage(status);
alertDialog.setButton("Acknowledged", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
});
alertDialog.show();
感謝您的提示答案......真正欣賞它 – 2015-03-02 22:23:30