I\'m trying to create a ListView with a list of downloading tasks.
The downloading tasks are managed in a Service (DownloadService). Everyt
Although its not an answer to your question but one optimization that can be done in your getView() method is this, Instead of creating and setting click listener every time like this:
holder.downloadStateBtn.setTag(position);
holder.downloadStateBtn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
int position = (Integer) v.getTag();
// your current normal click handling
}
});
You can just create it once as class variable and set it while creating row's View:
final OnClickListener btnListener = new OnClickListener() {
@Override
public void onClick(View v) {
int position = (Integer) v.getTag();
// your normal click handling code goes here
}
}
and then in getView():
if (v == null) {
v = mLayoutInflater.inflate(R.layout.saved_show_list_item, parent, false);
// your ViewHolder stuff here
holder.downloadStateBtn.setOnClickListener(btnClickListener);//<<<<<
v.setTag(holder);
} else {
holder = (ViewHolder) v.getTag();
}
oh and don't forget to set tag on this button in getView() as you are already doing:
holder.downloadStateBtn.setTag(position);