Answer the question
In order to leave comments, you need to log in
How to implement click handling on imageview inside item Listview?
How to implement click handling on imageview inside item Listview?
I made my adapter. getView looks like this:
@Override
public View getView(int i, View v, ViewGroup viewGroup)
{
View rootView = v;
if (rootView == null) {
rootView = layoutInflater.inflate(R.layout.item_cat, viewGroup, false);
}
CatSounds s = getSounds(i);
((TextView) rootView.findViewById(R.id.textNameCat)).setText(s.nameCat);
imageCatPlay = (ImageView) rootView.findViewById(R.id.imageCatPlay);
imageCatPlay.setTag(i);
imageCatPlay.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view)
{
Log.d("myLogs", "нажата в позиции = " + view.getTag());
((ImageView) view.getTag()).setImageResource(R.drawable.pause);
}
});
return rootView;
}
java.lang.ClassCastException: java.lang.Integer cannot be cast to android.widget.ImageView
((ImageView) view.getTag()).setImageResource(R.drawable.pause);
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question