我有一个显示音乐名称的列表视图,当我选择音乐时,其中的1个音乐进度条在它下面可见。问题是当我点击第1时它自动也选择4等等,即2为它选择5 3- 8 .. 我认为当适配器保持足够的值时,它不会在屏幕向下滚动时一次性加载,因此当我在批次1中选择第一项时,它也会选择前一批次的第一项。 这是代码:
public View getView(final int position, View convertView, ViewGroup parent) {
View v = convertView;
if (convertView == null) {
// here we inflate the layout
LayoutInflater li = getLayoutInflater();
v = li.inflate(R.layout.music_videos_sublayout, null);
} else {
v = convertView;
}
if (mediaflag == 1) {
ImageView media_image = (ImageView) v
.findViewById(R.id.media_type);
media_image.setBackgroundResource(R.drawable.video);
} else {
ImageView media_image = (ImageView) v
.findViewById(R.id.media_type);
media_image.setBackgroundResource(R.drawable.music);
}
ImageView club_image = (ImageView) v.findViewById(R.id.clubimage_music_videos_sublayout);
TextView club_name = (TextView) v.findViewById(R.id.clubname_music_videos_sublayout);
club_name.setText(mediaArraylist.get(position).getClubName());
TextView mediaName = (TextView) v.findViewById(R.id.songname_music_videos_sublayout);
mediaName.setText(mediaArraylist.get(position).getMedianame());
AQuery aQuery = new AQuery(MusicVideosActivity.this);
String thumbnail = mediaArraylist.get(position).getClubimage();
Bitmap preset = aQuery.getCachedImage(thumbnail);
club_image.setImageBitmap(preset);
v.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View myView) {
System.out.println("Clicked within View"+position);
ProgressBar musicBar1 = (ProgressBar)v.findViewById(R.id.progressBar1);
musicBar1.setVisibility(View.VISIBLE);
}
});
return v;
}
答案 0 :(得分:0)
使用bin并将boolean变量设置为getview中的isAvail,将此行放入...
musicbar1.setVisibility(listitem.isAvail() ? View.VISIBLE : View.GONE);