如何在MaterialSearchView中添加项目单击的侦听器
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_grids);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
sharedPreferences = getSharedPreferences(MyPref, Context.MODE_PRIVATE);
editor = sharedPreferences.edit();
locationStatus =sharedPreferences.getString(locationStatus,"");
searchView.setOnItemClickListener( new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
String s=(String)parent.getItemAtPosition(position);
Toast.makeText(getBaseContext(),s,Toast.LENGTH_LONG).show();
}
});
我尝试了这段代码,但项目点击监听器无效
我之前确实有这样的问题,我从qazxsw poi找到解决方案
很长的短篇小说我把它放在我的代码上
搜索ゔiew。 Setsu b Miton C ck(true);
并且它会将sugestion文本作为查询提交,或者你可以添加它来获取监听器
this guys