[英]Android dynamically change keys in soft keyboard
我的自定義視圖有一個問題,該視圖包含一個編輯文本和一個微調框。 我使用IMEoptions添加了“下一步”按鈕。 根據微調器,edittext鍵盤應包含“ next”或“ done”鍵。
目前,我使用以下方法解決此問題:
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int position, long id) {
final Object item = adapterView.getItemAtPosition(position);
if (item.equals(getString(STRING1))) {
edittext.setImeOptions(EditOptions.IME_OPTIONS_NEXT);
} else if(item.equals(getString(STRING2)){
edittext.setImeOptions(EditOptions.IME_OPTIONS_ACTION_DONE);
}
edittext.setText(edittext.getText());
//This updates the edittext but is very much an ugly hack.
//Is there another way to update this? invalidate() and forceLayout()
//does not do the trick
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.