I would like to disable copy/paste actions when I use the SearchView
in Toolbar
.
Actually I don't want to have the native copy/past bar which appears on top.
答案 0 :(得分:3)
You can use this method:
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void disableSearchViewActionMode(SearchView searchView) {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
((EditText) searchView.findViewById(R.id.search_src_text)).setCustomSelectionActionModeCallback(new ActionMode.Callback() {
@Override
public boolean onCreateActionMode(ActionMode mode, Menu menu) {
return false;
}
@Override
public boolean onPrepareActionMode(ActionMode mode, Menu menu) {
return false;
}
@Override
public boolean onActionItemClicked(ActionMode mode, MenuItem item) {
return false;
}
@Override
public void onDestroyActionMode(ActionMode mode) {
}
});
}
}