为了账号安全,请及时绑定邮箱和手机立即绑定

在searchView.setOnQueryTextListener下把内容put 到map中,list里没有任何显示

在searchView.setOnQueryTextListener下把内容put 到map中,list里没有任何显示

盐汽水 2016-12-27 14:22:26
public List<Map<String, Object>> mData=new  ArrayList<Map<String, Object>>(); @Override   public boolean onCreateOptionsMenu(Menu menu) {      MenuInflater inflater = getMenuInflater();      inflater.inflate(R.menu.buy, menu);      searchItem = menu.findItem(R.id.action_search);      searchView = (SearchView) searchItem.getActionView();      // 配置SearchView的属性  //    searchView.setOnQueryTextListener(this);//监听输入框字符串变化            searchView.setSubmitButtonEnabled(true);//显示查询提交按钮                searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() { @Override public boolean onQueryTextSubmit(String arg0) { // TODO Auto-generated method stub return false; } @Override public boolean onQueryTextChange(String arg0) { // TODO Auto-generated method stub int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null); getSearch = ((EditText)searchView.findViewById(id)).getText().toString();  List<Map<String, Object>> list = new ArrayList<Map<String, Object>>(); Map<String, Object> map = new HashMap<String, Object>(); cursor=dbHelper.getReadableDatabase().rawQuery("select * from dict where id ='"+getSearch+"'",null); Log.i("记录数",String.valueOf(cursor.getCount())); num=cursor.getCount(); Log.i("num",String.valueOf(num)); if(num>0){ cursor.moveToFirst(); for(int i=0;i<num;i++) { map = new HashMap<String, Object>(); int columnIndex=cursor.getColumnIndex("id"); rthing[i]=cursor.getString(columnIndex); map.put("title","Test" ); int columnIndex3=cursor.getColumnIndex("question2"); rphone[i]=cursor.getString(columnIndex3); map.put("info","Test" ); Log.i("phone",rphone[i]); int columnIndex4=cursor.getColumnIndex("passwd"); rpath[i]=cursor.getString(columnIndex4); map.put("img",R.drawable.p45 ); list.add(map); cursor.moveToNext(); } }//Toast.makeText(BuyActivity.this, "信息有误", 2000).show(); cursor.moveToFirst(); return false; } });                     return super.onCreateOptionsMenu(menu);   }  谢谢各位大神!!!!帮小弟看一下
查看完整描述
  • 3 回答
  • 0 关注
  • 3774 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信