0
A
回答
5
嘗試這樣:
TableLayout table = new TableLayout(this);
for (int i = 0; i < mRows; i++) {
TableRow tr = new TableRow(mContext);
tr.setLayoutParams(new TableRow.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT));
for (int j = 0; j < mCols; j++) {
ImageView view = new ImageView(this);
view.setImageResource(R.drawable.star_on)
tr.addView(view);
}
table.addView(tr);
}
這個程序生成整個表/格。你可以看到它如何實例化ImageView並設置圖像。
相關問題
- 1. 如何以編程方式將TableRow從xml添加到TableLayout?
- 2. Android以編程方式添加ImageView
- 3. 以編程方式添加imageView時OutOfMemoryError
- 4. 以編程方式將ImageView添加到子活動
- 5. 以編程方式將ImageView添加到佈局
- 6. 如何以編程方式將多個ImageView添加到Framelayout?
- 7. 以編程方式將列表中的項目添加到TableLayout中
- 8. 以編程方式調整TableLayout中的ImageView的大小
- 9. 以編程方式向Android上的TableLayout添加內容
- 10. 編程方式添加到的TableRow不TableLayout工作
- 11. Android以編程方式創建TableLayout
- 12. 以編程方式創建TableLayout
- 13. 以編程方式滾動TableLayout
- 14. 以編程方式安裝TableLayout
- 15. 以編程方式訂購TableLayout列值
- 16. 以編程方式添加到畫布
- 17. 以編程方式添加視圖以匹配父級以填充TableLayout
- 18. ImageView - 如何充氣或以編程方式添加?
- 19. android以編程方式添加ImageView選擇器
- 20. 返回片段後以編程方式添加ImageView
- 21. 如何以編程方式在imageView底部添加標籤?
- 22. 以編程方式添加ImageView Inside Base Adapter
- 23. 用自己的onTouchListener以編程方式添加ImageView
- 24. 如何以編程方式向ImageView添加圓形形狀Android
- 25. 編程添加Imageview
- 26. 以編程方式將子視圖添加到NIB的方法
- 27. 以編程方式將視圖添加到片段onCreateView方法
- 28. 以編程方式將應用程序添加到IIS網站
- 29. 以編程方式將Podcast Feed添加到Podcast應用程序
- 30. 以編程方式將按鈕添加到UWP應用程序
你如何設置圖片瀏覽寬度和高度?我想讓他們32 * 32,但我不能。怎麼做呢? – 2012-05-27 22:47:04