可能重复:
How to display content from sqlite using ViewFlipper in android
我有来自sqlite的数据,我想在sqlite中使用viewflipper的帮助逐个显示数据,因为我正在使用哈希映射。要更清楚我现在在sqlite中有2条记录我希望显示第一条记录,然后通过翻转显示我正在使用
cache = new ArrayList<String>();
while (cursor.moveToNext())
{
String temp_bookid = cursor.getString(0);
Log.i("temp_bookid",temp_bookid);
String temp_desc=cursor.getString(1);
byte[] temp_image1 = cursor.getBlob(2);
byte[] temp_image2 = cursor.getBlob(3);
String temp_id=cursor.getString(4);
String temp_name = cursor.getString(5);
String temp_bname=cursor.getString(6);
cache.add(temp_id);
cache.add(temp_bname);
cache.add(temp_bookid);
cache.add(temp_name);
cache.add(temp_desc);
cache.add(temp_image1.toString());
cache.add(temp_image2.toString());
Log.i("temp_id of the page in sqlite", temp_id);
TextView txtDesc = (TextView) findViewById(R.id.tDescription);
text = (TextView) findViewById(R.id.tTitle);
text.setText(temp_name);
txtDesc.setText(temp_desc);
ImageView img = (ImageView)findViewById(R.id.smallImage);
img.setImageBitmap(BitmapFactory.decodeByteArray(temp_image1, 0,temp_image1.length));
txtName1 = (TextView) findViewById(R.id.tvName);
txtName1.setText(temp_bname);
break;
}
mContext = this;
vf = (ViewFlipper) this.findViewById(R.id.vfShow);
vf.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(final View view, final MotionEvent event) {
detector.onTouchEvent(event);
Log.i("ew","ae");
return true;
}
});
使用上面的代码我只能设置第一个记录数据,因为我正在使用break;声明,如果我删除休息;它显示了最后一条记录..