转载请标明出处:http://blog.csdn.net/wu_wxc/article/details/46846309
本文出自【吴孝城的CSDN博客】
在不同的输入框,我们会看到输入法软键盘右下角的字或符号会有所不同
有的显示为一个回车图标,有的是连接,有的是发送等不同的值可以监听特定的动作或事件
<EditText android:id="@+id/net_address" android:layout_height="wrap_content" android:imeOptions="actionGo" android:layout_width="match_parent"/>
EditText dt = (EditText)findViewById(R.id.editText); et.setOnEditorActionListener(new OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int actionId, KeyEvent event) { if (actionId == EditorInfo.IME_ACTION_SEARCH) { Toast.makeText(getActivity(), "1111111",Toast.LENGTH_SHORT).show(); } return false; } });
<EditText android:id="@+id/net_address" android:layout_height="wrap_content" android:imeOptions="actionGo" android:layout_width="match_parent" android:singleLine="true" />
<EditText android:id="@+id/net_address" android:layout_height="wrap_content" android:imeOptions="actionGo" android:layout_width="match_parent" android:inputType="text"/>Java代码的设置
editText.setImeOptions(EditorInfo.IME_ACTION_SEARCH); editText.setInputType(EditorInfo.TYPE_CLASS_TEXT); editText.setSingleLine(true);