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


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);  

}  

谢谢各位大神!!!!帮小弟看一下

盐汽水
浏览 3775回答 3
3回答

在路上_3498046

加油,看不懂了

慕的地8582982

TJLPMWMJLOYBXORAKNKTVKDZHKUDHXNDZBEOJGQZQTJMYTDGQMQTIEBVRNWMPEBDTPRZXZRGJZILCOKBWMBKGCZDYBXOETJZOFBGWTIYNDFOYWGCYHRULHDAJTPFVRNVFOSINROIBLLVHMSVLSUFFVLXOOYUKNNPFVOBEWYCFOELEARYGCSZPTWDGWJYNBDNXYYBTWSUSCICLBRRBXJJXWMYSVFYNJDYEOTJTDDPMRKAAHNTDTORAOOVBRRFPIOFIXNQQTWQGIVFMHYPYMMJFIYYICPCQXRQKHCWWWCCZUQESSCCAZACACZGAAWHJDDSOLVEXHECHECILHHXDDQQWACGFZSFFSYTXDGJJJTDCQVHNTTYKHXUBAHZPCATHDCDXDANXUWQXSDKVRWJMZTGRBGMEIJJWWIYVYMBGZIDJQNIZPSWABLUBQDFGPWSQDSJMZXTDHHESIYSLFGGKGGQUXRJGZMZLLCSFCSCZVCFPRRYELSOLHBLNXJMKXXGAYRRUKHEEMTMCUOIPEBLWPAXYCZGIPZGKKATTJQXQKYEOXNPTWZFZWRCYAAZXDKYCPRLECJZCRXFKQTKQZQCJPQCUKJDEUAHFHGTWMZTZCTWSEMPMKBNXAUUBYIBRVDGDXLUICUUNDALVIHBAUMZZWKESIPCWLNHAURCOIBSDYUKXLJNQHBBOAATXXTREOKDQJQPMMDBLFFJIRLGCGGGSFFHENHNSVZSWWVPVSFJMMCSOGWAIZXJCJZQMJTUQADNGHQDBFTPDHJJMFMTNOFAMDDAQDAUZGGFVVYCWKXOUEYVBERXFSSNYMYNDYKRLQPXAHKNVLMPFXNNERRAQBURHTKUVSMYZNZJPQAKYQJGPYVVOSCCCVIV
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

Android
Java