On the activit added sheet I see, with a large number of elements, when scrolling, all the elements are highlighted. I would like to remove this effect =)

ordinary view

when trying to scroll with your finger

public class ListAdapter extends ArrayAdapter<Task> implements OnClickListener, OnCreateContextMenuListener { private List<Task> tasks; public ListAdapter(Context context, List<Task> tasks) { super(context, R.layout.rowlayout, tasks); this.tasks = tasks; } static class ViewHolder { public TextView title, timeField; public Date dateStart; public Date dateFinish; public ImageView icon; } Task task; ViewHolder holder; long time; ArrayList<Task> taskList = new ArrayList<Task>(); @Override public View getView(int position, View convertView, ViewGroup parent) { task = tasks.get(position); View view = convertView; if (view == null) { LayoutInflater inflater = (LayoutInflater) getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE); view = inflater.inflate(R.layout.rowlayout, null); holder = new ViewHolder(); holder.icon = (ImageView) view.findViewById(R.id.subj_icon); holder.title = (TextView) view.findViewById(R.id.title); holder.timeField = (TextView) view.findViewById(R.id.start_date); view.setTag(holder); } else { holder = (ViewHolder) view.getTag(); } // view.setTag(holder); view.setTag(R.id.progressBar, task); holder.title.setText(task.getTitle()); holder.timeField.setText(Utility.formatDate(task.getDateStart()) + " - " + Utility.formatDate(task.getDateEnd())); view.setOnClickListener(this); updateIcon(); return view; } public void updateIcon() { int i = task.getPriority(); int excellent = task.getComplet(); if (excellent != 100) { switch (i) { case 0: holder.icon.setImageResource(R.drawable.btn_rating_star_off_normal); break; case 1: holder.icon.setImageResource(R.drawable.btn_rating_star_off_pressed); break; case 2: holder.icon.setImageResource(R.drawable.btn_rating_star_off_selected); break; default: break; } } else { switch (i) { case 0: holder.icon.setImageResource(R.drawable.btn_rating_star_on_normal); break; case 1: holder.icon.setImageResource(R.drawable.btn_rating_star_on_pressed); break; case 2: holder.icon.setImageResource(R.drawable.btn_rating_star_on_selected); break; default: break; } } } public void onClick(View v) { Intent intent = new Intent(getContext(), TaskActivity.class); intent.putExtra(IDKeys.UID, ((Task)v.getTag(R.id.progressBar)).getID()); getContext().startActivity(intent); } /**************************************************************************************** * * Context Menu * ****************************************************************************************/ public static final int IDM_DELETE = 102; public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { menu.add(Menu.NONE, IDM_DELETE, Menu.NONE, "DELETE"); } } 

UPD.1

  1. in Figure 1 (with asterisks) - ListView (its code is attached)
  2. when you try to scroll it with your finger on the device screen (or in the emulator), we get the result, in Fig. 2. Ie all items stand out as one
  • Attach a bit of your code. But it is not entirely clear. What I see in the screenshot is that you just don’t draw naming. - KoVadim
  • the names are drawn, black color - these are all elements highlighted, I thought to simply remove the selection when clicking on an element, but it doesn’t work out yet, I think the reason for this, because I have a view on the activation, and it counts as 1 element that stands out completely, not item by item - Gorets
  • Honestly, I tried for 3 minutes to understand what was happening and didn’t understand :) Write the text in more detail. Not obvious somehow ... - DroidAlex

3 answers 3

I put a background on my row_layout.xml - the effect is gone ....

    If you have the same pictures in several elements, then the idea is to use the same list item there, try to remove the ViewHolder altogether, and always set the view parameter to null so that the view is recreated. Such thoughts. Xs, because of this, it's a cant, but it's worth a try.

    • black appears when selected, i.e. everything is drawn there normally, the text is not visible on the screenshots, due to the fact that it merges with black, but if you put the text color red it is visible - Gorets

    android: cacheColorHint = "# 00000000" Need to add to xml ListView