1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | private ListView PlanList; private EditText typingText; public void showSpot () { typingText = (EditText)findViewById(R.id.typingText); PlanList = (ListView)findViewById(R.id.PlanList); ArrayList<HashMap<String, Object>> itemList = new ArrayList<HashMap<String, Object>>(); for (int i = 0; i < latList.length; i++) { HashMap<String, Object> planItems = new HashMap<String, Object>(); planItems.put("spot", spotList[i]); planItems.put("day", queList[i]+ "-" + "Day:" + dayList[i]); if (flagList[i].equals("1")) { planItems.put("pic1", R.drawable.food_icon); } itemList.add(planItems); } final SimpleAdapter spotAdapter = new SimpleAdapter (Map2Activity.this, itemList, R.layout.my_list_layout02, new String[] {"spot", "day", "pic1"}, new int[] {R.id.my_textView1, R.id.my_textView2, R.id.imageView1}); PlanList.setAdapter(spotAdapter); PlanList.setTextFilterEnabled(true); typingText.addTextChangedListener(new TextWatcher() { public void onTextChanged(CharSequence s, int start, int before, int count) { spotAdapter.getFilter().filter(s); } public void beforeTextChanged(CharSequence s, int start, int count, int after) {} public void afterTextChanged(Editable s) {} }); } |
Direct link: https://paste.plurk.com/show/1549511