Android动态更改软键盘中的键

时间:2012-05-02 11:37:03

标签: android android-edittext android-softkeyboard

我的自定义视图存在问题,其中包含edittext和微调器。我使用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
}

0 个答案:

没有答案