I am trying to retrieve all member data from my database and then display it on a listview and it is able to work.
Now I am trying to search for a particular member and i managed to retrieve the records (logged into the logcat) but it doesn't refresh my listview accordingly.
This is the list view codes I used to retrieve the searched records.
SimpleAdapter simpleAdapter = new SimpleAdapter(Search.this, productsList, R.layout.list_item, new String[] {TAG_COMPANY},
new int[] { R.id.name});
lv = (ListView) findViewById(R.id.lst_name);
lv.setAdapter(simpleAdapter);
This is because. you need to let the ListView
know that a change in your data has occurred. To notify the ListView
about the change, you need to call:
simpleAdapter.notifyDataSetChanged();
If for some reason it didn't work, you can also reassign the adapter of your ListView
:
simpleAdapter = new SimpleAdapter(...);
lv.setAdapter(yourAdapter);
simpleAdapter.notifyDataSetChanged();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.