I have a ListView and I need to update the content of specifics rows without reload all the ListView content.This ListView can be big.
For example (for do it simple) I need to change the content of a TextView (label3 in the adapter) located in a view (the row) at the 'x' position of the adapter. Actually I work with a TouchListView (Commonsware) adapter.
class IconicAdapter extends ArrayAdapter<FavoriteObject> {
IconicAdapter() {
super(FavoritesMainActivity.this, R.layout.favbusrow, array);
}
public View getView(int position, View convertView,ViewGroup parent) {
View row=convertView;
LayoutInflater inflater=getLayoutInflater();
ListFav lf = (listFav) array.get(position).getContent();
row=inflater.inflate(R.layout.favrow,parent, false);
row.setBackgroundColor(Color.WHITE);
TextView label=(TextView)row.findViewById(R.id.busNameF);
label.setText(lf.getName());
label.setTextColor(Color.BLACK);
label.setTypeface(FontsManager.getBoldFont());
TextView label2 =(TextView)row.findViewById(R.id.busNumberF);
label2.setText(lf.getNumber());
label2.setTextColor(Color.BLACK);
label2.setTypeface(FontsManager.getBoldFont());
TextView label3 =(TextView)row.findViewById(R.id.busDirectionF);
label3.setText(lf.getQuickName());
label3.setTextColor(Color.BLACK);
label3.setTypeface(FontsManager.getRegularFont());
return(row);
}
}
Someone have an idea?
Thanks!
Update the data set within your adapter to reflect your changes and then call notifyDataSetChanged() on your adapter.
I need to change the content of a TextView (label3 in the adapter) located in a view (the row) at the 'x' position of the adapter.
That position may or may not be in view. You can use getFirstVisiblePosition() and getLastVisiblePosition() to see if it is, then calculate the child index and use getChildAt() to retrieve the row.
You also need to ensure that your data model reflects this change, so as the user scrolls, they do not "lose" whatever direct-to-UI modification you make.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With