Добрый день. Я создал ListView
с кастомизированным Adapter'ом.
public class SurahAdapter extends ArrayAdapter<Surah> {
Context context;
int layoutResourceId;
Surah data[] = null;
public SurahAdapter(Context context, int layoutResourceId, Surah[]data){
super(context,layoutResourceId, data);
this.context = context;
this.layoutResourceId = layoutResourceId;
this.data = data;
}
@Override
public View getView(int position, View convertView, ViewGroup parent){
ArtistHolder holder = null;
View row = convertView;
if(row == null)
{
LayoutInflater inflater = ((Activity)context).getLayoutInflater();
row = inflater.inflate(layoutResourceId, parent, false);
holder = new ArtistHolder();
holder.suraTitle = (TextView)row.findViewById(R.id.suraTitle);
holder.verseCount = (TextView)row.findViewById(R.id.verseCount);
holder.place = (TextView)row.findViewById(R.id.place);
holder.surahBG = (ImageView)row.findViewById(R.id.surahBG);
row.setTag(holder);
}
else
{
holder = (ArtistHolder)row.getTag();
}
Surah surah = data[position];
holder.suraTitle.setText("Сура " + surah.suraTitle);
holder.verseCount.setText(surah.verseCount);
holder.place.setText(surah.place);
holder.surahBG.setImageResource(surah.surahBG);
return row;
}
static class ArtistHolder
{
TextView suraTitle;
TextView verseCount;
TextView place;
ImageView surahBG;
}
}
В MainActivity
присваиваю ListView
свой Adapter
SurahAdapter adapter = new SurahAdapter(this,
R.layout.surah_lv_layout, surah);
suraLV.setAdapter(adapter);
Необходимо, чтобы при нажатии на элемент списка, он менял картинку из ImageView surahBG
на иконку воспроизведения звуковой дорожки. Подскажите как это организовать?