当前位置:编程学习 > wap >>

怎么将二进制转为图片并显示在程序上呢。新手 急!!!!!!!在线等


        protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.driverinfo);

init(); // 初始化

}

public void init() {

Intent intent = getIntent();
String img = intent.getStringExtra("textImg");

Bitmap bitmap = Bytes2Bimap(img.getBytes()); // 转换图片

         ImageView image1 = (ImageView) findViewById(R.id.siji_img_id);

image1.setImageBitmap(bitmap); // 设置Bitmap

}

// 将二进制 转为 Bitmap
private Bitmap Bytes2Bimap(byte[] b) {
if (b.length != 0) {
return BitmapFactory.decodeByteArray(b, 0, b.length);
} else {
return null;
}
}



在  xml中 是这么写的

<ImageView
android:id="@+id/siji_img_id"
android:maxWidth="100dp"
android:maxHeight="100dp"
/>

我已经有  图片的二进制码了, 求教如何显示在 Android程序上

求教大神,哪里出错了,    最好能贴出代码,   后天+xml的都要,  谢谢,   在线等,,急!!!! --------------------编程问答-------------------- ImageView iv = findViewById(R.id.siji_img_id);
iv.setImageBitmap(bitmap); --------------------编程问答-------------------- oncreate应该是public --------------------编程问答-------------------- 求教大神,哪里出错了,到底该怎么做 最好能贴出代码, 后台 + xml的都要, 谢谢, 在线等,,急!!!!    帖子别沉啊   跪求 --------------------编程问答-------------------- 改了 public了,  可还是不行 --------------------编程问答-------------------- xml文件名字是driverinfo.xml吗? --------------------编程问答-------------------- 如果还不行那就是传值的问题了,你得把你传值的代码发过来看看
补充:移动开发 ,  Android
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,