Have problem with repeating items reaction to click in custom adapter list view.
Actually method in onClick applying for clicked element and if i scroll down my list some of elements repeats the same.
So when i'm try to solve it with Tag its not help me.
I'm try to use different realization which find on Stack and Google but it can't help also.
That is my lust code of realization
public class CAChanal extends BaseAdapter {
private Context context;
protected MainActivity MAcontext;
public CAChanal(MainActivity _context){
MAcontext = _context;
}
public CAChanal(Context context) {
this.context = context;
}
ArrayList<DMChanal> listArray;
public CAChanal() {
listArray = new ArrayList<DMChanal>();
}
@Override
public int getCount() {
return listArray.size();
}
@Override
public Object getItem(int i) {
return listArray.get(i);
}
@Override
public long getItemId(int i) {
return i;
}
@Override
public View getView(int index,View view, ViewGroup parent) {
final ViewHolder holder ;
if (view == null) {
LayoutInflater inflater = LayoutInflater.from(parent.getContext());
view = inflater.inflate(R.layout.chanal_template, null);
holder = new ViewHolder();
holder.chanalElement=(ChanalView)view.findViewById(R.id.chanalView_forList);
view.setTag(holder);
}else
{
holder = (ViewHolder)view.getTag();
}
holder.chanalElement.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if(!holder.chanalElement.getChanalStatus())
{
holder.chanalElement.enableChanal();
}else
{
holder.chanalElement.disableChanal();
}
}
});
return view;
}
static class ViewHolder {
ChanalView chanalElement;
}
public Object getFilter() {
return null;
}
}
Can any one help me to solve my problem and explain what can be wrong in my code. P.S: ChanalView is my custom view