将图像URL转换为Drawables

时间:2017-03-11 15:57:10

标签: java android

我需要将图片网址转为Drawable,以便我可以在int数组中使用它。

我想提出d0d1d3等,而不是R.drawable.sample_0R.drawable.sample_1等。

我不明白为什么R.drawable.photosint检测为Drawable而我的Drawable不是?{/ p>

如何将int转为public void callEditActivity(){ Intent myIntent = new Intent(context, BirdsGalleryActivity.class); img0 = myIntent.getExtras().getString("IMG0"); img1 = myIntent.getExtras().getString("IMG1"); img2 = myIntent.getExtras().getString("IMG2"); img3 = myIntent.getExtras().getString("IMG3"); img4 = myIntent.getExtras().getString("IMG4"); } URL url0 = new URL(img0); URL url1 = new URL(img1); URL url2 = new URL(img2); URL url3 = new URL(img3); URL url4 = new URL(img4); Bitmap bmp0 = BitmapFactory.decodeStream(url0.openConnection().getInputStream()); Bitmap bmp1 = BitmapFactory.decodeStream(url1.openConnection().getInputStream()); Bitmap bmp2 = BitmapFactory.decodeStream(url2.openConnection().getInputStream()); Bitmap bmp3 = BitmapFactory.decodeStream(url3.openConnection().getInputStream()); Bitmap bmp4 = BitmapFactory.decodeStream(url4.openConnection().getInputStream()); Drawable d0 = new BitmapDrawable(bmp0); Drawable d1 = new BitmapDrawable(bmp1); Drawable d2 = new BitmapDrawable(bmp2); Drawable d3 = new BitmapDrawable(bmp3); Drawable d4 = new BitmapDrawable(bmp4); private int[] GalImages = new int[] { R.drawable.sample_0, R.drawable.sample_1, R.drawable.sample_2, };

<th:block th:switch="${item}">
  <input th:case="1" />
  <span th:case="*" />
</div>

0 个答案:

没有答案