2015-11-11 105 views
1

我在編輯文本的XML文件中使用此代碼。軟鍵盤,edittext setImeActionLabel()不起作用?

<EditText 
      android:id="@+id/et_login_password" 
      android:layout_width="match_parent" 
      android:layout_height="@dimen/fragment_login_views_height" 
      android:layout_below="@+id/et_login_email" 
      android:ems="10" 
      android:hint="password" 
      android:inputType="textPassword" 
      android:text="Vidcode2015" 
      android:textColor="@color/primary_dark" 
      android:textColorHint="@android:color/tertiary_text_light" 
      android:textSize="@dimen/fragment_login_views_text_size" /> 

而在java文件我設置edittext屬性。

et_password.setImeActionLabel("Login",EditorInfo.IME_ACTION_SEND); 
     et_password.setOnEditorActionListener(new TextView.OnEditorActionListener() { 
      @Override 
      public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { 
       boolean handled = false; 
       if (actionId == EditorInfo.IME_ACTION_SEND) { 
        performLogin(et_user.getText().toString(), et_password.getText().toString()); 
        handled = true; 
       } 
       return handled; 
      } 
     }); 
+0

檢查http://stackoverflow.com/questions/1538331/android-cant-figure-how-to-use-setimeactionlabel –

+0

你可以使用'imeOptions' –

回答

0

的Android只能通過imeOptions具有特定標籤的提供編輯文本上softkeyboard按鈕設置,比如做或發送e.t.c.用戶不能設置他/她自己的標籤,如登錄或abc等

+0

這不是真的。 setImeActionLabel(「Login」,EditorInfo.IME_ACTION_SEND)適用於'冰淇淋三明治',但不適用於'棒棒糖' – GenericTeaCup