我需要將多個ImageView加載到佈局。 ImageViews用於顯示使用'star'圖標的評分。恆星(即等級的數量由讀取配置文件加載期間確定將多個ImageView添加到佈局
的ImageViews正坐在一個RelativeLayout的佈局裏面
目前我使用的是這樣的:。
RelativeLayout l = ((RelativeLayout)(findViewById(R.id.RelativeLayout01)));
for (int nStarCount = 0; nStarCount < config.getAsInt("stars", 1); nStarCount ++) {
ImageView image = new ImageView(this);
image .setImageResource(R.drawable.star);
image .setAdjustViewBounds(true);
l.addView(i);
}
我的問題是:
1)是做動態加載(不使用XML)是這樣做的'正確的方式?
2)如果是這樣,我該如何讓星星排成一行,目前他們將一個放在另一個的上面。
任何幫助,將不勝感激。
RM
你有什麼需要在這篇文章中,? – 2011-08-17 07:47:47