私は、ネットから取り出したイメージを含むバイト配列を持っています。私は怠惰に私のUIアクティビティ(または私は少なくともBitmapfactory、BitmapDrawableとsetImageDrawableを使用してしようとしている)にそれらを読み込んでいます。ここに私のコードは次のとおりです。ここsetImageBitmapは目に見える効果がありません
RelativeLayout r =(RelativeLayout) adap.getGroupView(Integer.parseInt(groupPos), false, null, null);
ImageView iv = (ImageView) r.findViewById(R.id.imgGruppo);
Log.w("",""+raw_img.length);
Bitmap bm = BitmapFactory.decodeByteArray(raw_img, 0, raw_img.length);
Drawable drawable = new BitmapDrawable(bm);
Log.i("","pre setimage");
iv.setImageDrawable(drawable);
//added for testing only, with no effects.
//((ELA) Activity_Titoli_2.this.getExpandableListAdapter()).notifyDataSetChanged();
//ELA is my expandable list adapter
Log.i("","post setimage"+bm.getRowBytes()); //just to see that i have actual data in raw_img and such
はXMLが
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/linearLayoutTitoli2_gruppo"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textNomeGruppo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="Large Text"
android:textColor="#FF0000"
android:padding="14dp"
android:textAppearance="?android:attr/textAppearanceLarge" />
<TextView
android:id="@+id/textNoteGruppo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textNomeGruppo"
android:paddingLeft="14dp"
android:paddingRight="14dp"
android:paddingBottom="7dp"
android:text="Small Text"
android:textAppearance="?android:attr/textAppearanceSmall" />
<ImageView
android:id="@+id/imgGruppo"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:src="@drawable/icon"
/>
</RelativeLayout>
を関与している私が、「アンドロイド:SRC ...」追加したImageViewのが見えて、それがある場合にだけチェックします。唯一の問題は私がそれを変更することができないということです! 私が作成したビットマップのみを使用してsetImageBitmapを試しました。setimageDrawableを使用してBitmapDrawableを作成しようとしましたが、効果はまったくありませんでした。エラーも何もない。 どうか、間違いはありますか?ありがとうございます
をビットマップを設定するには、以下の関数を呼び出しますか? –
コードにinvalidate()を追加すると、何も変更されません –
、建設的なことは何も言わずに下降した男のおかげです。歓声、男。 –