First: You are not creating a new ViewHolder when convertView
is null
.
Second: You have a ViewHolder instance as a member variable of the class and you continually manipulate this ViewHolder. There should be one ViewHolder instance per row item on screen and you should create and manipulate the ViewHolder **only within getView()*.
Instead of this:
private ViewHolder holder;
@Override
public View getView(int position, View convertView, ViewGroup parent) {
holder = ...;
setData();
}
private void setData() {
holder.tv_name.setText(...);
// etc.
}
Do this:
// no private ViewHolder instance
@Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder = ...; // create new or getTag
setData(holder);
}
private void setData(ViewHolder holder) {
holder.tv_name.setText(...);
// etc.
}