簡體   English   中英

如何在Android鍵盤上添加按鈕

[英]How to add a Button on top of an Android keyboard

大家好我在我的項目中分配了一個任務,我需要在Android鍵盤的頂部添加一個完成按鈕。在我的屏幕上我有一個EditText,每當我點擊EditText它應該打開一個鍵盤和“完成” “Android鍵盤頂部的按鈕。所以我可以將一個監聽器附加到該按鈕來執行我的任務。任何建議。

感謝和問候,ENKrishna。

如果需要鍵盤來顯示“完成”按鈕,則需要在EditText中對其進行定義

    <EditText android:text="EditText" android:layout_width="fill_parent"
android:id="@+id/editText1" android:layout_height="wrap_content"
android:imeOptions="actionDone"/>

然后,您可以在用戶使用OnEditorActionListener按下“完成”按鈕時OnEditorActionListener

class DoneOnEditorActionListener implements OnEditorActionListener {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
    if (actionId == EditorInfo.IME_ACTION_DONE) {
        InputMethodManager imm = (InputMethodManager)v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
        imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
        return true;    
    }
    return false;
}

}

如果你讀到這個,你的答案就可以找到。

即IME行動的概念。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM