問題描述
我想要做的是更改虛擬鍵盤中顯示的默認(rèn)完成"標(biāo)簽.這是我沒有運(yùn)氣的嘗試:
What I want to do is change the default "Done" label that appears in the virtual keyboard. Here's what I've tried without any luck:
mSearchInput.setImeOptions(EditorInfo.IME_ACTION_DONE);
mSearchInput.setImeActionLabel(getString(R.string.search_action_label), EditorInfo.IME_ACTION_DONE);
但是,我能夠處理對(duì)該按鈕的點(diǎn)擊,方法是:
I am able, however, to handle a click on that button, with this:
mSearchInput.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_DONE) {
performSearch();
return true;
}
return false;
}
});
目前我不知道如何更改該按鈕上的標(biāo)簽.
I'm clueless as to how I can change the label on that button at the moment.
推薦答案
imeActionLabel
設(shè)置全屏 IME 模式(即當(dāng)您的手機(jī)在在風(fēng)景中).如果要更改鍵盤右下角的按鈕,可以將某些標(biāo)志傳遞給 imeOptions
.
The imeActionLabel
sets the label for the button that appears on the top right on full screen IME mode (i.e., when your phone is in landscape). If you want to change the button to the bottom right of the keyboard, you can pass certain flags to imeOptions
.
據(jù)我所知,對(duì)于該按鈕,您僅限于一組特定的操作(請(qǐng)參閱 here 獲取支持的標(biāo)志的完整列表),但是由于您似乎想要一個(gè)搜索按鈕,您所要做的就是稍微調(diào)整您的第一行并使用 IME_ACTION_SEARCH
:
As far as I know, for that button you're limited to a certain set of actions (see here for a full list of supported flags), but since you seem to want a search button, all you have to do is to slightly adjust your first line and use IME_ACTION_SEARCH
:
mSearchInput.setImeOptions(EditorInfo.IME_ACTION_SEARCH);
請(qǐng)注意,該按鈕的確切外觀將取決于輸入法.默認(rèn)的 Android 鍵盤顯示搜索標(biāo)志的放大鏡,而 Touch Input(HTC 的鍵盤)似乎完全不知道該標(biāo)志,仍然顯示返回按鈕.
Mind you, the exact appearance of that button will depend on the input method. The default Android keyboard shows a magnifier for the search flag, while the Touch Input (HTC's keyboard) seems completely unaware of that flag, still showing a return button.
這篇關(guān)于Android:不知道如何使用 setImeActionLabel的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!