当我尝试将bytearray转换为位图时,我得到了null。我不知道为什么。请给我有用的建议。
super.onCreate(savedInstanceState);
setContentView(R.layout.newscreen);
TextView name = (TextView)findViewById(R.id.textView1);
TextView age = (TextView)findViewById(R.id.textView2);
ImageView img = (ImageView)findViewById(R.id.imageView1);
db = openOrCreateDatabase(
"StudentData.db"
, SQLiteDatabase.CREATE_IF_NECESSARY
, null
);
db.setVersion(1);
db.setLocale(Locale.getDefault());
db.setLockingEnabled(true);
Cursor cur = db.query("stuData",
null, null, null, null, null, null);
//cur.moveToFirst();
cur.moveToFirst();
//name.setText(cur.getString(1));
//age.setText(cur.getString(2));
// if(bb!=null)
//{
//ByteArrayInputStream imageStream = new ByteArrayInputStream(bb);
//bs = new BufferedInputStream(bb)
//img.setImageBitmap(theImage);
while (cur.isAfterLast() == false) {
BitmapFactory.Options options = new BitmapFactory.Options();
options.inSampleSize=5;
name.append("n" + cur.getString(1));
byte[] bb = cur.getBlob(3);
System.out.print("DAta"+bb);
for(int i =0;i<bb.length;i++)
{
System.out.println(bb[i]);
}
Bitmap theImage = BitmapFactory.decodeByteArray(cur.getBlob(3),0,cur.getBlob(3).length);
img.setImageBitmap(theImage);
cur.moveToNext();
}
cur.close();
答案 0 :(得分:0)
有几点需要检查。