安卓:更改键盘上的"Done"按钮文本



我是Android开发的新手。是否可以在键盘上更改"完成"按钮的文本?如果是,该怎么做?

  EditText input = new EditText(context);
  input.setImeOptions(EditorInfo.IME_ACTION_DONE);
  input.setImeActionLabel("My Text", EditorInfo.IME_ACTION_DONE);

另外,您可以在XML

中执行此操作
  android:imeActionLabel="My Text"

您可以在XML中为TextView设置Imeoptions。他们的很多这Imeoptions的链接

例如各种imeoptions ..

actionNone       IME_ACTION_NONE.
actionGo         IME_ACTION_GO.
actionSearch     IME_ACTION_SEARCH.
actionSend       IME_ACTION_SEND.
actionNext       IME_ACTION_NEXT.
android:imeOptions="actionDone"

使用这样的使用:

   <EditText       
        android:layout_width="match_parent"
        android:layout_height="wrap_content"            
        android:imeOptions="actionGo"           
     />

并将此功能称为使用操作:

mInstrunctionEditTxt
        .setOnEditorActionListener(new OnEditorActionListener() {
            @Override
            public boolean onEditorAction(TextView v, int actionId,
                    KeyEvent event) {
                if (actionId == EditorInfo.IME_ACTION_GO) {
                    // do what action you want
                }
                return false;
            }               

        });

最新更新