Android Textview Value
I have some problem I want to change my textview value. when my code change it will change here is the code public class SubMenuActivity extends Activity { private static final in
Solution 1:
compare like this
if(tx1.getText().toString().equals("1"))
{
tx1.setText("7");
}
Solution 2:
Strings can not be compared with ==
operator they can be compared with .equals
method
so change your code to this
if(tx1.toString().equals("1"))
{
tx1.setText("7");
}
Solution 3:
Instead of
if(tx1.toString()=="1".toString()) {
tx1.setText("7");
}
try this
if(tx1.getText().toString().equals("1")) {
tx1.setText("7");
}
Solution 4:
You need to Compare the variable like.equal(Object/String)
if(tx1.toString().equals("1"))
{
tx1.setText("7");
}
Solution 5:
in java "==" means the address is the same, instead, you can use .equel() which comes from the basic class "object".
Post a Comment for "Android Textview Value"