试试这个
在XML文件中
<EditText
android:id="@+id/rechercheTextView"
android:layout_width="174dp"
android:layout_height="wrap_content"
android:background="@android:color/transparent"
android:imeOptions="actionSearch"
android:inputType="text"
/>
在活动
EditText rechTxt = (EditText) findViewById(R.id.rechercheTextView);
rechTxt.setOnEditorActionListener(new OnEditorActionListener() {
public boolean onEditorAction(TextView v, int actionId,
KeyEvent event) {
if (actionId == EditorInfo.IME_ACTION_SEARCH) {
Toast.makeText(getApplicationContext(),"search",Toast.LENGTH_LONG).show();
return true;
}
return false;
}
});
它的工作原理是在你按下回车键时,正确的行动,但我认为谷歌决定不切换按钮外观/键盘布局。 – zapl