Reputation: 479
I wrote a code in java that should get a number from an EditText
by clicking on a button and print it in console.that's so simple but when I click on the edittext in order to write a number in it I see this message in logcat
that
:
09-16 23:57:02.121: W/Editor(27812): GetLabel fail! Do framework orig behavior
and after clicking on the button nothing happens!
this is a part of my code :
EditText txt1=(EditText)findViewById(R.id.editText1);
Editable t1;
t1=txt1.getText();
if(!(t1.toString().equalsIgnoreCase("0") || t1.toString().equalsIgnoreCase("null"))){
int n1 = Integer.parseInt(t1.toString());
int m1 = n1/100000;
System.out.print(n1);
System.out.print(m1);
}
I'll be happy if anyone can help me by that :)
Upvotes: 0
Views: 824
Reputation: 2084
Try this;
EditText editText=(EditText) findViewById(R.id.editText1);
String text = editText.getText().toString();
if( text!=null && !text.equalsIgnoreCase("0") ) {
int num1 = Integer.parseInt(text);
int num2 = num1/100000;
Log.d(TAG, "Num1 " + num1);
Log.d(TAG, "Num2 " + num2);
}
Upvotes: 0
Reputation: 479
if anyone faced to the same problem as mine , just be sure that there's no problem with this warning :"
09-16 23:57:02.121: W/Editor(27812): GetLabel fail! Do framework orig behavior
just pay attention more ! maybe you have done something funny like me :
System.out.print(n1);
System.out.print(m1);
I solved my problem by changing print
with println
....
so simple ;-)
Upvotes: 0
Reputation: 13233
When you compare Strings
you should use the equals()
on the String
Class
.
Upvotes: 1