There is a ListView in which there are 1000 elements and when scrolling through the list quickly there is an effect like that of a car’s wheel, first it goes in one direction and then back, although in fact it turns in the right direction, how can you get rid of this effect? Perhaps for a large number of items in the list need another adapter?
ListViewAdapter.java
public class ContactListAdapter extends BaseAdapter { private Context context; private static final String TAG = "ContactListAdapter"; ArrayList<Contact> list; private LayoutInflater layoutInflater; private ViewHolder preHolder; private ViewHolder secondHold; public ContactListAdapter(Context context, ContactList contactList) { this.context = context; list = contactList; layoutInflater = (LayoutInflater) this.context.getSystemService(Context.LAYOUT_INFLATER_SERVICE); } public void setList(ArrayList<ContactCaling> list) { this.list = list; } public static class ViewHolder { private View rootView; private TextView tvName; private TextView tvInitials; private ImageView ivAvatart; private ImageView ivStatus; private RelativeLayout relativeLayoutParent; private RelativeLayout relativeLayoutMain; private RelativeLayout onlineButtonContainer; private RelativeLayout timeoutButtonContainer; private RelativeLayout relativeLayout_exit_buuton_conteiner; private RelativeLayout relativeLayout_icon_phone; private String contactName; private boolean isShow; private ContactCaling contactCaling; } @Override public View getView(final int position, final View convertView, final ViewGroup parent) { final ViewHolder holder; if (convertView == null) { holder = new ViewHolder(); holder.rootView = convertView; LayoutInflater layoutInflater = (LayoutInflater) context .getSystemService(Context.LAYOUT_INFLATER_SERVICE); holder.rootView = layoutInflater.inflate(R.layout.main_contact_list_item, null); holder.tvName = (TextView) holder.rootView.findViewById(R.id.textView_contact_name); holder.tvInitials = (TextView) holder.rootView.findViewById(R.id.textView_contact_initials); holder.ivAvatart = (ImageView) holder.rootView.findViewById(R.id.imageView_contact_avatar); holder.ivStatus = (ImageView) holder.rootView.findViewById(R.id.imageView_status); holder.relativeLayoutParent = (RelativeLayout) holder.rootView.findViewById(R.id.relativeLayout_parent); holder.relativeLayoutMain = (RelativeLayout) holder.rootView.findViewById(R.id.relativeLayout_main); holder.onlineButtonContainer = (RelativeLayout) holder.rootView.findViewById(R.id.relativeLayout_call_button_container); holder.relativeLayout_icon_phone = (RelativeLayout) holder.rootView.findViewById(R.id.relativeLayout_icon_phone); holder.timeoutButtonContainer = (RelativeLayout) holder.rootView.findViewById(R.id.relativeLayout_call_busy_button_container); holder.relativeLayout_exit_buuton_conteiner = (RelativeLayout) holder.rootView.findViewById(R.id.relativeLayout_exit_buuton_conteiner); /**-------------Item listener---------------**/ holder.relativeLayoutParent.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if (preHolder == null || (secondHold != null && secondHold.equals(holder))) { if (MyApplication.isOnline()) { int buttonTranslation = -holder.onlineButtonContainer.getLayoutParams().width + 2; holder.onlineButtonContainer .animate() .translationX(buttonTranslation) .setDuration(350); secondHold = null; } else { int buttonTranslation = -holder.timeoutButtonContainer.getLayoutParams().width + 2; holder.timeoutButtonContainer .animate() .translationX(buttonTranslation) .setDuration(350); secondHold = null; } } if (preHolder != null) { if (MyApplication.isOnline()) { int translate = preHolder.onlineButtonContainer.getLayoutParams().width; preHolder.relativeLayoutMain .animate() .translationX(0) .setDuration(350); preHolder.onlineButtonContainer .animate() .translationX(translate) .setDuration(350); } else { int translate = preHolder.timeoutButtonContainer.getLayoutParams().width; preHolder.relativeLayoutMain .animate() .translationX(0) .setDuration(350); preHolder.timeoutButtonContainer .animate() .translationX(translate) .setDuration(350); } } if (preHolder != null) { preHolder = null; } else { preHolder = holder; } secondHold = holder; } }); holder.isShow = false; holder.rootView.setTag(holder); } else { holder = (ViewHolder) convertView.getTag(); } holder.contact = (Contact) getItem(position); holder.contactName = holder.contact.getDisplayName(); holder.tvName.setText(holder.contactName); setIcons(position, holder); return holder.rootView; } @Override public int getCount() { return list.size(); } @Override public Object getItem(int position) { return list.get(position); } @Override public long getItemId(int position) { return position; } }