【问题标题】:Adding Images to Drawable Folder from a Server将图像从服务器添加到可绘制文件夹
【发布时间】:2012-02-06 15:34:06
【问题描述】:

当用户从服务器选择他选择的图像时,我需要将图像动态添加到 res/drawable 文件夹中......然后将相应的R.drawable.imageid 存储到数据库中......以便在下一个加载用户选择的图像跑……有没有办法……?

int[] images = {
   R.drawable.m1,R.drawable.m2, R.drawable.m3,                      
   R.drawable.m4,R.drawable.m5, R.drawable.m6,
   R.drawable.m7, R.drawable.m8,
   R.drawable.m9
               };

ImageView iv = (ImageView)findViewById(imageViews[next]);
iv.setImageResource(images[j]);  

这里R.drawable.m1R.drawable.m2R.drawable.m3R.drawable.m4R.drawable.m5R.drawable.m6R.drawable.m7R.drawable.m8R.drawable.m9应该是用户从服务器选择的图像的ID

【问题讨论】:

  • 提问时请不要大喊大叫。这使它们更难阅读。您也不需要将相同的信息放入标签中的标题中,如果您使用真实的单词(“the”而不是“d”,“should”而不是“shd”等)会有所帮助);并非所有可能为您提供帮助的人都是以英语为母语的人(或理解噪音),您的问题越清晰,您就越有可能很快得到答案。谢谢。 :)

标签: android


【解决方案1】:

Quoting安卓工程师RomainGuy

你不能写入 res/drawable。

但是您可以寻找其他替代方案,例如 external storage

要考虑的链接是

android image save to res/drawable folder

How to convert a Drawable to a Bitmap?

Android: Image save to location

【讨论】:

    【解决方案2】:

    你不能复制drawable文件夹中的图片。

    在数据文件夹中创建文件夹并在其中写入图像并使用位图类来映射图像。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-01-29
      • 2010-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多