我有这个代码,它使用webservice获取已经转换为字符串的BLOB图像.这是JSON输出.
{driver_name: "Anna BIEndia" taxi_plate_no: "NUV 900" driver_contact_no: "09169271825" driver_operator: "grab" driver_operator_address: "987 Buendia St. California" image: "iVBORw0KGgoAAAANSUhEUgAACDQAAAXcCAYAAADXlEzmAAAACXBIWX..."}
这是我在androID中的代码,它获取JsON并在布局中显示它.除图像外,其他值均已显示.
public class DriverDetails extends Activity {ArrayList<Objects> objectsList = new ArrayList<>();String url = "http://192.168.1.110:8080/taxisafe3/displays/taxIDetails";@OverrIDeprotected voID onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentVIEw(R.layout.activity_driver_details); new Task().execute(url);}public class Task extends AsyncTask<String, String, String> { @OverrIDe protected voID onPreExecute() { super.onPreExecute(); } @OverrIDe protected String doInBackground(String... strings) { String content = httpulRConnect.getData(url); return content; } @OverrIDe protected voID onPostExecute(String s) { try { TextVIEw Title1 = (TextVIEw) findVIEwByID(R.ID.textVIEw3); TextVIEw Title = (TextVIEw) findVIEwByID(R.ID.textVIEw2); TextVIEw Title2 = (TextVIEw) findVIEwByID(R.ID.textVIEw7); TextVIEw Title3 = (TextVIEw) findVIEwByID(R.ID.textVIEw9); TextVIEw Title4 = (TextVIEw) findVIEwByID(R.ID.textVIEw11); ImageVIEw image = (ImageVIEw) findVIEwByID(R.ID.imageVIEw2); JsONArray ary = new JsONArray(s); for (int i = 0; i < ary.length(); i++) { JsONObject Jsonobject = ary.getJsONObject(i); Objects objects = new Objects(); objects.setDriver_name(Jsonobject.getString("driver_name")); objects.setTaxi_plate_no(Jsonobject.getString("taxi_plate_no")); objects.setDriver_operator(Jsonobject.getString("driver_operator")); objects.setDriver_operator_address(Jsonobject.getString("driver_operator_address")); objects.setDriver_contact_no(Jsonobject.getString("driver_contact_no")); objects.setimage(Jsonobject.getString("image")); objectsList.add(objects); if (Title1 != null){ Title1.setText(objects.getDriver_name()); } if (Title != null){ Title.setText(objects.getTaxi_plate_no()); } if (Title2 != null){ Title2.setText(objects.getDriver_operator()); } if (Title3 != null){ Title3.setText(objects.getDriver_operator_address()); } if (Title4 != null){ Title4.setText(objects.getDriver_contact_no()); } if(image != null){ byte[] decodedString = Base64.decode(objects.getimage(), Base64.DEFAulT); Bitmap decodedByte = BitmapFactory.decodeByteArray(decodedString, 0, decodedString.length); image.setimageBitmap(decodedByte); } } } catch (JsONException e) { e.printstacktrace(); }}}}
我的代码有什么问题,为什么图像不在ImageVIEw中显示?提前致谢. 总结
以上是内存溢出为你收集整理的android – Base64到Bitmap在ImageView中显示全部内容,希望文章能够帮你解决android – Base64到Bitmap在ImageView中显示所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)