android中的光标适配器滚动列表时填写错误的图像

时间:2010-12-11 08:42:20

标签: android listview cursor adapter

我有光标适配器的问题,我有自定义适配器,其中有图像,文本,复选框,一切正常,但作为一个当我滚动列表与30项目一些图像disarrange和文本显示正常。

问题是什么,我必须修复任何属性或更改实现,所有时候我的图像来自从数据库中提取的游标。

代码是:

@Override
        public View getView(int position, View convertView, ViewGroup parent) {
            return super.getView(position, convertView, parent);
        }

        @Override
        public void bindView(View view, Context context, final Cursor cursor) {


            Image = (ImageView) view.findViewById(R.id.CoverArtImage);
            byte[] theByteArray = cursor.getBlob(4);
            if (theByteArray != null) {
                Bitmap bitmap = BitmapFactory.decodeByteArray(theByteArray, 0,
                        theByteArray.length);
                Image.setImageBitmap(bitmap);
                bitmap = null;
                theByteArray = null;
            }

            tText = (TextView) view.findViewById(R.id.TrackTextView);
            tText.setText(cursor.getString(2));

            aText = (TextView) view.findViewById(R.id.ArtistTextView);
            aText.setText(cursor.getString(3));

            aText = (TextView) view.findViewById(R.id.AlbumTextView);
            aText.setText(cursor.getString(1));

            dateText = (TextView) view.findViewById(R.id.DateTimeTextView);
            dateText.setText(cursor.getString(5));

            deletecheckBox.setTag(cursor.getString(0));
            deletecheckBox.setOnClickListener(new View.OnClickListener() {

                public void onClick(View v) {
                    CheckBox chk = (CheckBox) v;
                    if (chk.isChecked()) {
                        deleteId.add(chk.getTag().toString());
                        // System.out.println("Chaked......" + chk.getTag());
                    } else {
                        deleteId.remove(chk.getTag().toString());
                        // System.out.println("UnChaked......" + chk.getTag());
                    }
                }
            });
        }

        @Override
        public View newView(Context context, final Cursor cursor,
                ViewGroup parent) {
            final View view = mInflater.inflate(R.layout.histrory_row, parent,
                    false);
            view.setOnClickListener(HistoryDetails.this);
            view.setTag(cursor.getString(0));
            deletecheckBox = (CheckBox) view.findViewById(R.id.DeleteCheckbox);
            bindView(view, context, cursor);
            return view;
        }

由于

0 个答案:

没有答案