Android:按钮启用属性不工作
我有编辑文本中的字符串,我想通过该字符串更改按钮状态。请帮我解决这个问题,我是android的初学者。 这是代码Android:按钮启用属性不工作,android,Android,我有编辑文本中的字符串,我想通过该字符串更改按钮状态。请帮我解决这个问题,我是android的初学者。 这是代码 String Result = jsonResult.toString(); JSONObject jsonResponse = new JSONObject(Result); int successValue = jsonResponse.getInt("success"); String messageValue= jsonResponse.getString("message
String Result = jsonResult.toString();
JSONObject jsonResponse = new JSONObject(Result);
int successValue = jsonResponse.getInt("success");
String messageValue= jsonResponse.getString("message");
String successStringValue = String.valueOf(successValue);
String messageStringValue = String.valueOf(messageValue);
t1.setText(messageStringValue);
String tt1=t1.getText().toString();
if (tt1 != "Appointment is ready."){
b1.setEnabled(true);}
else{
b1.setEnabled(false);}
通过执行“.equals()”来比较刺
通过执行“.equals()”来比较刺
通过执行“.equals()”来比较刺
通过执行“.equals()”将您的条件更改为
if (tt1.equalsIgnoreCase("Appointment is ready.")){
b1.setEnabled(true);
}
else
{
b1.setEnabled(false);
}
使用此代码使edittext不可编辑
<EditText ...
android:clickable="false"
android:cursorVisible="false"
android:focusable="false"
android:focusableInTouchMode="false">
</EditText>
将您的条件更改为
if (tt1.equalsIgnoreCase("Appointment is ready.")){
b1.setEnabled(true);
}
else
{
b1.setEnabled(false);
}
使用此代码使edittext不可编辑
<EditText ...
android:clickable="false"
android:cursorVisible="false"
android:focusable="false"
android:focusableInTouchMode="false">
</EditText>
将您的条件更改为
if (tt1.equalsIgnoreCase("Appointment is ready.")){
b1.setEnabled(true);
}
else
{
b1.setEnabled(false);
}
使用此代码使edittext不可编辑
<EditText ...
android:clickable="false"
android:cursorVisible="false"
android:focusable="false"
android:focusableInTouchMode="false">
</EditText>
将您的条件更改为
if (tt1.equalsIgnoreCase("Appointment is ready.")){
b1.setEnabled(true);
}
else
{
b1.setEnabled(false);
}
使用此代码使edittext不可编辑
<EditText ...
android:clickable="false"
android:cursorVisible="false"
android:focusable="false"
android:focusableInTouchMode="false">
</EditText>
如果要比较字符串,则必须使用比较值而非引用的equals()
,如果条件不正确,则它将起作用。您的问题是,==
比较引用,这不起作用。您需要比较值,因此为此,您必须使用equals()
方法。在if()中使用tt1.equalsIgnoreCase(“约会准备就绪”)将起作用如果您要比较字符串,则必须使用比较值而非引用的equals()
。您的问题是,==
比较引用,这不起作用。您需要比较值,因此为此,您必须使用equals()
方法。在if()中使用tt1.equalsIgnoreCase(“约会准备就绪”)将起作用如果您要比较字符串,则必须使用比较值而非引用的equals()
。您的问题是,==
比较引用,这不起作用。您需要比较值,因此为此,您必须使用equals()
方法。在if()中使用tt1.equalsIgnoreCase(“约会准备就绪”)将起作用如果您要比较字符串,则必须使用比较值而非引用的equals()
。您的问题是,==
比较引用,这不起作用。您需要比较值,因此为此必须使用equals()
方法。在if()中使用tt1.equalsIgnoreCase(“约会准备就绪”)