Reputation: 2153
I have an EditText , after I write something and I click next i want to do a call to server. for example if i have edittext a, how I specify that the action has to happen just after I click next ? I suppose that a.setOnClickLisner is not ok
Thank you in advance , Raluca
Upvotes: 0
Views: 1363
Reputation: 6612
Try this...
editText = (EditText) findViewById(R.id.editText);
editText.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
// PLACE CODE FOR CALLING SERVER.
return false;
}
return false;
}
});
Upvotes: 1
Reputation: 33258
try this....
EditText.setOnEditorActionListener(new OnEditorActionListener()
{
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event)
{
if(actionId==EditorInfo.IME_ACTION_NEXT)
{
//Write your code here
}
return false;
}
});
Upvotes: 1