android中的光标适配器滚动列表时填充错误的图像
我的光标适配器有问题,我有自定义适配器,其中有图像、文本、复选框,一切正常,但当我滚动包含 30 个项目的列表时,一些图像混乱,文本显示正常。
问题是什么,我必须修复任何属性或更改实现,只要我的图像来自从数据库获取的光标。
代码是:
@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;
}
谢谢
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, context, cursor);
return view;
}
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论