Hi Any reply is precious for me and appriciated as well
in one edit text i am setting onKeyListener
so that when I enter 5 numerics in edittext it will accept n do next process but in samsung galaxy tablet it is not working i am using these lines of code
zipcode.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
System.out.println("setOnKeyListenersetOnKeyListenersetOnKeyListenersetOnKeyListenersetOnKeyListenersetOnKeyListenersetOnKeyListener");
if (event.getAction() == KeyEvent.ACTION_UP && zipcode.getText().length() == 5) {
System.out.println("OnKeyListener11111");开发者_C百科
started = true;
searchByZipcode(zipcode.getText().toString());
}
return false;
}
});
searchByZipcode(zipcode.getText().toString());
line takes the text we are writing in to webservice but in galaxy flow doesnt get into onKeylistner can any1 pls help me out thanks
That's odd. Only in Samsung Galaxys? Is this the full Listener? Maybe you have some other method catching KeyEvent
s that return true
?
Try replacing the code for onKey()
by onKeyUp()
, which is a TextView
method:
http://developer.android.com/reference/android/widget/TextView.html#onKeyUp%28int,%20android.view.KeyEvent%29
BTW, why do you add return false;
? Is there any other Listener that requires to handle the KeyEvent
? If not, I would suggest to change it for return true;
If you handled the event, return true. If you want to allow the event to be handled by the next receiver, return false.
精彩评论