Modify inputType:number|phone Android Studio

40 Views Asked by At

Is it possible to modify inputType:Phone in android studio somehow? It would be handy to get the # * keys to other icons and submit. The only way to submit now is to press back button on the phone to get out of the input-keypad.

1

There are 1 best solutions below

0
Salar Arabpour On BEST ANSWER

add these two lines in your EditText xml

<EditText 
 android:imeOptions="actionGo"
 android:inputType="number"/>
//the action button of keyboard will change to go button

then you can set on click of that button in java

edittext.setOnEditorActionListener(new OnEditorActionListener() { 
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_GO) {
        Log.i(TAG,"Here you can perform actions");   //like btn.performClick();
        return true;
    }    
    return false;
}
});