家伙,我真的想打开一个Activity与Intent从Searchview。我不知道该怎么做,这是我的代码String dataArr[] = { "Kiambu county","Kisumu county","Kitui county", "Laikipia county","Lamu county","Makongeni county", "Meru county","Mombasa county","Muranga county", "Nairobi county","Nakuru county","Narok county", "kajiado county","kiambu county","Uansingishu county"};ArrayAdapter<String> newsAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, dataArr);mSearchAutoComplete.setAdapter(newsAdapter);// Listen to search view item on click event.mSearchAutoComplete.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) { if (i==0){ Intent intent=new Intent(County.this,Kiambu.class); } }});// Below event is triggered when submit search query.searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String query) { AlertDialog alertDialog = new AlertDialog.Builder(County.this).create(); alertDialog.setMessage("Search keyword is " + query); alertDialog.show(); return false; } @Override public boolean onQueryTextChange(String newText) { return false; }});我真的很感激帮助,当我搜索一个词并点击它时,它会把我带到另一个班级
添加回答
举报
0/150
提交
取消