【问题标题】:having issues with setting up a picture in a custom listview. help needed在自定义列表视图中设置图片时遇到问题。需要帮助
【发布时间】:2013-08-04 10:48:55
【问题描述】:

大家好,我的问题有点难以解释,我会尽力解释..

之前我使用 detail.setIcon(R.drawable.ic_launcher);//之前 setIcon 只接受 int 值 但后来我不得不使用这个函数来设置图像 detail.setIcon(BitmapFactory.decodeByteArray(rawArt, 0, rawArt.length, bfo));这里我传递的值的类型已经改变......这里的“bfo”是位图类型。 这意味着我必须更改适配器中的值,我之前使用此行来设置图像 image.setImageResource(sng.icon);which accpets int 值,这意味着我将不得不改变“setImageResource”的东西来接受位图............any1可以帮我吗???

ImageView image = (ImageView) v.findViewById(R.id.icon);//this is the part of adapter
image.setImageResource(sng.icon);//this is the part of adapter


detail.setIcon(R.drawable.ic_launcher);

.......................

ImageView image = (ImageView) v.findViewById(R.id.icon);//this is the part of adapter
image.setImageResource(sng.icon);//this is the part of adapter which needs to be changed now

BitmapFactory.Options bfo=new BitmapFactory.Options();
detail.setIcon(BitmapFactory.decodeByteArray(rawArt, 0, rawArt.length, bfo)); 

另一种方法是我将位图解析为 int.....any1 知道我可以实现吗??

【问题讨论】:

    标签: android imageview bitmapfactory custom-adapter


    【解决方案1】:

    好吧,我搜索了一下,我发现我可以使用这个代码 image.setImageBitmap(sng.icon)

    而不是这个 image.setImageResource(sng.icon)

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-02-23
      • 1970-01-01
      • 2020-09-29
      • 2014-02-05
      相关资源
      最近更新 更多