修改 inputType:number|phone Android 工作室

Modify inputType:number|phone Android Studio

是否可以通过某种方式在 android 工作室中修改 inputType:Phone? 获取其他图标的 # * 键并提交会很方便。现在提交的唯一方法是按 phone 上的后退按钮退出输入键盘。

在您的 EditText 中添加这两行 xml

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

然后您可以在 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;
}
});