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 =)
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
- in Figure 1 (with asterisks) - ListView (its code is attached)
- 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