多くのネストされたLinearLayoutsとTextViewssを持つLinearLayoutがあります
私の主な活動は、メインのLinearLayoutを膨らませます。
次に、サーバーからデータをロードし、受信したデータに基づいて、プレースホルダーに複数のレイアウトを追加します(LinearLayout)
これは単純なニュースページで、ニュースに関連付けられた画像を読み込み、最初は空のLinearLayout内に配置します。
各画像には次の情報があります:Title(TextView)、Date(TextView)、Image(ImageView)なので、実際に行うことは次のとおりです。
*これは私がすべてのtry->catch... if / else....etcを要素化した質問にコード化された必須のものにすぎないことに注意してください
public void addImages(JSONArray images){
ViewGroup vg = (ViewGroup) findViewById(R.id.imagesPlaceHolder);
// loop on images
for(int i =0;i<images.length;i++){
View v = getLayoutInflater().inflate(R.layout.image_preview,vg);
// then
I think that here is the problem
ImageView imv = (ImageView) v.findViewById(R.id.imagePreview);
TextView dt = (TextView) v.findViewById(R.id.dateHolder);
TextView ttl = (TextView) v.findViewById(R.id.title);
// then
dt.setText("blablabla");
ttl.setText("another blablabla");
// I think the problem is here too, since it's referring to a single image
imv.setTag( images.getJSONObject(i).getString("image_path").toString() );
// then Image Loader From Server or Cache to the Image View
}
}
上記のコードは、単一の画像に適しています
しかし、複数の画像の場合、画像ローダーは機能しません。これは、すべてのImageView(複数回膨張)が同じIDを持っているためだと思います。