我们大家都知道通过指定EditText的android:imeOptions属性可以修改 输入法enter键的显示情况
例如:
android:imeOptions=”actionNext” 下一个配合android:nextFocusForward属性一起使用
android:imeOptions=”actionSearch” 搜索
android:imeOptions=”actionDone” enter
android:imeOptions=”actionGo” 前往
如果我们单独只设置android:imeOptions这个属性的话,我们会悲剧的发现.输入法的enter键一直都不会有变化
例如:
<EditText
android:id="@+id/etext_done"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:imeOptions="actionDone"
/>
而我们如果加上 android:inputType=””
然后随便指定一种输入类型.我们的imeOptions属性也就起作用了
所以使用的时候记得设置
在activity或者fragment来监听点击了enter go 或者 search
edittext.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
/*判断是否是“GO”键*/
if(actionId == EditorInfo.IME_ACTION_GO){
/*隐藏软键盘*/
InputMethodManager imm = (InputMethodManager) v
.getContext().getSystemService(
Context.INPUT_METHOD_SERVICE);
if (imm.isActive()) {
imm.hideSoftInputFromWindow(
v.getApplicationWindowToken(), 0);
}
edittext.setText("success");
webview.loadUrl(URL);
return true;
}
return false;
}
});
文章出处
http://blog.youkuaiyun.com/u010399316/article/details/50569506