开发者

Cursor adapter in android Fill wrong image when scroll the list

I have problem with cursor adapter, i have custom adapter in which there is image,text,check box, all works fine but as an when i scroll list with 30 item some images disarrange and text show fine.

what is the problem, i have to fix any property or change implementation all time my image come from cursor which fetch from databases.

code is :

@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, c开发者_如何学JAVAontext, cursor);
            return view;
        }

Thanks

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜