Android List View Simple Adapter updating off screen but not on screen
I currently have a List View backed by a Simple Adapter. I am able to update the Simple Adapter values fine, however, they do not update on the list view unless the view goes off screen.. then when it returns to the screen it is updated. Ive tried everything like listview.refreshDrawableState and listview.invalidate to simpleadapter.notifyDataSetChanged and nothing makes it update on the screen, the views have to be scrolled off screen then back on to get updated.
Thank you to whoever responds =)
public View getView(int position, View convertView, ViewGroup parent)
{
View v = convertView;
if (v == null)
{
开发者_StackOverflow中文版 LayoutInflater vi = (LayoutInflater)getSystemService(Context.LAYOUT_INFLATER_SERVICE);
v = vi.inflate(R.layout.machine_list, null);
}
HashMap<String, String> map = machineListView.get(position);
if (map != null)
{
TextView status = (TextView)findViewById(R.id.statusText);
TextView numAlarms = (TextView)findViewById(R.id.alarmText);
if (status != null)
status.setText(map.get(status));
if (numAlarms != null)
status.setText(map.get(numAlarms) + " Alarms");
}
return v;
}
this may not be the best way but I simply reset the listView adapter whenever I want to refresh the whole view.
精彩评论