When I Click On "done" Button On Softkeybord How To Go Next Activity Android
when i click on softkeyboard my keyboard getdown or hide but i want to go to next activity when i click on 'done ' button on keyboard of android.so how to do it? and my next qus is
Solution 1:
Its is better to add some button in the layout as all android phones dont provide a consistent behaviour when using imeoptions.
This seems to be a bug. Different manufacturers make a customized keyboard for their phone which may not completely behave as the android standard keyboard. This issue has been raised before. Most people overcome this issue by either overiding the onKey event or using a TextWatcher class. A bug has been filed about this
http://code.google.com/p/android/issues/detail?id=2882
You can use a listener to check for imeoptions
incomeInput.setOnEditorActionListener(newEditText.OnEditorActionListener() {
@OverridepublicbooleanonEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE){
//Do your stuff herereturntrue; // mark the event as consumed
}
returnfalse;
}
}
Solution 2:
You need to implement OnEditorActionListener interface.
Code looks like :
publicclassMainextendsActivityimplementsOnEditorActionListener {
@OverrideprotectedvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main1);
}
publicbooleanonEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
startActivity(newIntent());
returntrue;
}
returnfalse;
}}
Solution 3:
Use setOnKeyListener with your second EditText and in onKey method do something like this.
@Override
public boolean onKey(View v, int keyCode, KeyEvent event)
{
// TODO Auto-generated method stubif(keyCode == KeyEvent.KEYCODE_ENTER && event.getAction() == KeyEvent.ACTION_DOWN)
performYourAction();
returnfalse;
}
I hope it will be helpfull for you.
Post a Comment for "When I Click On "done" Button On Softkeybord How To Go Next Activity Android"