setOnEditorActionListener不适用于Android Pie(9.0)
我试过一款setOnEditorActionListener,它适用于我的三星(安卓7.0版)设备。但它不适用于我的小米安卓手机(安卓9.0版)。我怎样才能解决这个问题 Java代码setOnEditorActionListener不适用于Android Pie(9.0),android,Android,我试过一款setOnEditorActionListener,它适用于我的三星(安卓7.0版)设备。但它不适用于我的小米安卓手机(安卓9.0版)。我怎样才能解决这个问题 Java代码 mSearchText.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView v, int
mSearchText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if(actionId == EditorInfo.IME_ACTION_SEARCH
|| actionId == EditorInfo.IME_ACTION_DONE
|| event.getAction() == KeyEvent.ACTION_DOWN
|| event.getAction() == KeyEvent.KEYCODE_ENTER){
//execute our method for searching
geoLocate();
}
return false;
}
});
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="@+id/ic_magnify"
android:layout_centerVertical="true"
android:textSize="15sp"
android:textColor="#000"
android:id="@+id/input_search"
android:background="@null"
android:hint="Enter Address, City or Zip Code"
android:imeOptions="actionSearch"
/>
XML代码
mSearchText.setOnEditorActionListener(new TextView.OnEditorActionListener() {
@Override
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
if(actionId == EditorInfo.IME_ACTION_SEARCH
|| actionId == EditorInfo.IME_ACTION_DONE
|| event.getAction() == KeyEvent.ACTION_DOWN
|| event.getAction() == KeyEvent.KEYCODE_ENTER){
//execute our method for searching
geoLocate();
}
return false;
}
});
<EditText
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_toRightOf="@+id/ic_magnify"
android:layout_centerVertical="true"
android:textSize="15sp"
android:textColor="#000"
android:id="@+id/input_search"
android:background="@null"
android:hint="Enter Address, City or Zip Code"
android:imeOptions="actionSearch"
/>
它与
android:inputType=“text”
将属性android:singleLine=“true”添加到edittext中对我很有用,正如这里建议的那样->您可以在这里找到有关此属性的更多信息->
et_search_members.setOnEditorActionListener(OnEditorActionListener{v,actionId,event->
if(actionId==EditorInfo.IME\u ACTION\u SEARCH){
sendSearchData()
}
假的
})