How to Disable "Next" Button on a Edittext Software Keyboard (Replace with "Done" Button)

How to disable Next button on a EditText software keyboard (replace with Done button)

Try adding android:imeOptions="actionDone" to your EditText.

Reference

How do I make an Android EditView 'Done' button and hide the keyboard when clicked?

Use TextView.setImeOptions and pass it actionDone.
like textView.setImeOptions(EditorInfo.IME_ACTION_DONE);

How to i can disable some button in edittext keyboard

You can't, sorry. After all, the input method editor may not have "keys" in the first place.

Specifically I want user can't input a ( , ) character when virtual keyboard is showed up when user focus on a standard android EditText widget.

Then you will have to block the input at the EditText, by means of an InputFilter, as is described here:

InputFilter filter = new InputFilter() {
public CharSequence filter(CharSequence source, int start, int end,
Spanned dest, int dstart, int dend) {
for (int i = start; i < end; i++) {
if (!Character.isLetterOrDigit(source.charAt(i))) {
return "";
}
}
return null;
}
};
edit.setFilters(new InputFilter[] { filter });

Android keyboard next button issue on EditText

add this lines below your lines of code you provided:

txtUserid.setOnKeyListener(new OnKeyListener() {

public boolean onKey(View v, int keyCode, KeyEvent event) {
// If the event is a key-down event on the "enter" button
if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
(keyCode == KeyEvent.KEYCODE_ENTER))
{
// Perform action on Enter key press
txtUserid.clearFocus();
txtUserPasword.requestFocus();
return true;
}
return false;
}
});

txtUserPasword.setOnKeyListener(new OnKeyListener() {

public boolean onKey(View v, int keyCode, KeyEvent event) {

if ((event.getAction() == KeyEvent.ACTION_DOWN) &&
(keyCode == KeyEvent.KEYCODE_ENTER))
{
// Perform action on Enter key press
// check for username - password correctness here
return true;
}
return false;
}
});

Android: How do I stop my edit text from going to next one?

I managed to fix this.

I added this to my root layout (which contained the edit text) and the problem no longer seems present

android:focusableInTouchMode="true"

Is there a way to disable the next button for an editText that is set to numbers?

You can include android:imeOptions="actionNone" on your <EditText> element in the manifest to say that you do not need an action button. There are other possibilities for android:imeOptions that might suit your needs better.

Bear in mind that there are hundreds of input method editors (soft keyboards) available for Android. Requests like android:imeOptions="actionNone" are hints, not demands. Whether the user's keyboard pays attention to actionNone is up to the developers of the keyboard.

How to disable Button if EditText is empty ?

    editText1.addTextChangedListener(new TextWatcher() {

@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {

if(s.toString().trim().length()==0){
button.setEnabled(false);
} else {
button.setEnabled(true);
}
}

@Override
public void beforeTextChanged(CharSequence s, int start, int count,
int after) {
// TODO Auto-generated method stub

}

@Override
public void afterTextChanged(Editable s) {
// TODO Auto-generated method stub

}
});

Change Done label on my softkeyboard to Search,Next according to EditText ime options

Finally I found it. Create a class which extends Keyboard and add the following method and call it from InputMethodService class.

@Override
protected Key createKeyFromXml(Resources res, Row parent, int x, int y, XmlResourceParser parser) {
Key key = new Key(res, parent, x, y, parser);
if (key.codes[0] == -4) {
mEnterKey = key;
}
return key;
}

private Key mEnterKey;
void setImeOptions(Resources res, int options) {
if (mEnterKey == null) {
return;
}

switch (options & (EditorInfo.IME_MASK_ACTION | EditorInfo.IME_FLAG_NO_ENTER_ACTION)) {
case EditorInfo.IME_ACTION_GO:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = "Go";
break;
case EditorInfo.IME_ACTION_NEXT:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = "Next";
break;
case EditorInfo.IME_ACTION_SEARCH:
mEnterKey.icon = null;
mEnterKey.iconPreview = null;
mEnterKey.label = "Search";
break;
case EditorInfo.IME_ACTION_SEND:
mEnterKey.iconPreview = null;
mEnterKey.icon = null;
mEnterKey.label = "Send";
break;
default:
mEnterKey.icon = null;
mEnterKey.iconPreview = null;
mEnterKey.label = "Return";
break;
}
}


Related Topics



Leave a reply



Submit