2017-05-07 8 views
-1

このチュートリアルのリンクにある同じ画像のすべてのリストビュー項目の画像を設定する方法はわかりませんでした。https://www.codeproject.com/Articles/507651/Customized-Android-ListView-with-Image-and-Text雪の中のxmlデータソースをデフォルト画像に変更すると出力に表示されません空白の表示私は1つの画像のすべてのリストを設定する部分のコーディングに変更を加えるなかった場所に必要なので、すべてのリスト項目の画像を設定する方法

答えて

0
BinderDataClassで

次のコードを削除:あなた定義することができますが、デフォルトで表示画像を変更したい場合は

String uri = "drawable/"+ weatherDataCollection.get(position).get(KEY_ICON); 
int imageResource = vi.getContext().getApplicationContext().getResources().getIdentifier(uri, null, vi.getContext().getApplicationContext().getPackageName()); 
Drawable image = vi.getContext().getResources().getDrawable(imageResource); holder.tvWeatherImage.setImageDrawable(image); 

をlist_row.xmlというリスト項目xmlファイルのImageViewのsrcプロパティを変更します。

<ImageView 

     android:id="@+id/list_image" 

     android:contentDescription="@string/app_name" 

     android:layout_width="60dip" 

     android:layout_height="60dip" 

     android:src="@drawable/sunny" /> 
関連する問題