2

我有一个显示音乐名称的列表视图,当我选择其中的 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;
    }
4

1 回答 1

0

使用 bin 并将布尔变量设置为 getview 中的 isAvail 将这一行...

musicbar1.setVisibility(listitem.isAvail() ? View.VISIBLE : View.GONE);
于 2012-11-20T12:23:23.053 回答