0

I have ListView filling It with an Adapter , I scroll in the ListView to view the next items, when I return to the items on the top of the list, I found that the data at the top is different than the first time ListView is initialized. I fill list using Api called From Server.

Matthew Shearer
  • 2,715
  • 3
  • 23
  • 32
AhmedAdel
  • 15
  • 9

3 Answers3

0

it's may help full to you.

@Override public int getViewTypeCount() {

return getCount();

}

@Override public int getItemViewType(int position) {

return position;

}

0
    if (convertView == null) {
            convertView = layoutInflater.inflate(R.layout.layout_row_myappointments, null);
            holder = new ViewHolder();

//your fields like below:

            holder.userName = (TextView) convertView.findViewById(R.id.username);

            convertView.setTag(holder);
        } else {
            holder = (ViewHolder) convertView.getTag();
        }

Try to change code like this in your getView()

Kuldeep Kulkarni
  • 796
  • 5
  • 20
0

Have you used ViewHolder to hold view in its position? If not then use it.

Here is the useful link:

https://stackoverflow.com/a/21501329/7391385

If you want full demo then try this:

https://dzone.com/articles/optimizing-your-listview

Community
  • 1
  • 1
Siddharth Sheth
  • 207
  • 2
  • 6