0
A
回答
0
一個Android應用程序您可以使用擴展BaseAdapter的ImageAdapter和u可以動態加載的圖像的任何觀點說gridview的n的所有...
public class ImageAdapter extends BaseAdapter {
private Context mContext;
public ImageAdapter(Context c) {
mContext = c;
}
public int getCount() {
return mThumbIds.length;
}
public Object getItem(int position) {
return null;
}
public long getItemId(int position) {
return 0;
}
// create a new ImageView for each item referenced by the Adapter
public View getView(int position, View convertView, ViewGroup parent) {
ImageView imageView;
if (convertView == null) { // if it's not recycled, initialize some attributes
imageView = new ImageView(mContext);
imageView.setLayoutParams(new GridView.LayoutParams(85, 85));
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
imageView.setPadding(8, 8, 8, 8);
} else {
imageView = (ImageView) convertView;
}
imageView.setImageResource(mThumbIds[position]);
return imageView;
}
// references to our images
private Integer[] mThumbIds = {
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7,
R.drawable.sample_0, R.drawable.sample_1,
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7,
R.drawable.sample_0, R.drawable.sample_1,
R.drawable.sample_2, R.drawable.sample_3,
R.drawable.sample_4, R.drawable.sample_5,
R.drawable.sample_6, R.drawable.sample_7
};
}
如果妳想要使用的GridView請參考以下鏈接: http://developer.android.com/resources/tutorials/views/hello-gridview.html
相關問題
- 1. 將圖片放在第二張圖片
- 2. Android,如何將圖片放在另一張圖片上?
- 3. Android:載入多張圖片
- 4. Android - 打印多張圖片
- 5. Android ACTION_VIEW多張圖片
- 6. Android合併兩張圖片
- 7. 放置圖片
- 8. 放一張圖片是div是空的
- 9. 連續設置4張圖片而不是2張圖片
- 10. 在主圖像下面居中放置3張圖片
- 11. Android - 將4張圖片放在2x2的網格中
- 12. 鑑於地圖
- 13. 在另一格放置多張圖片中的div
- 14. 上傳照片鑑於頁
- 15. Android圖片縮放
- 16. 將2張圖片放在同一行
- 17. Android圖庫 - 多張圖片 - 預先選擇的圖片
- 18. 如何將1到5張圖片放在另一張圖片上?
- 19. 如何在Google Maps API V3中放置2張圖片
- 20. 查找圖片,並放入另一張圖片來源
- 21. 兩張圖片之間的差異是否大於圖片?
- 22. Android在這張圖片的頂部繪製圖片(動態)
- 23. 張貼一張照片作爲開放圖facebook page
- 24. 選擇一張圖片,並上傳Android
- 25. Android歡迎屏幕 - 多張圖片
- 26. 在android中加載單張圖片
- 27. 基於重疊將多張圖像合併爲一張單張圖片
- 28. 幻燈片放映一次顯示2張圖片
- 29. CSS3背景圖片放置
- 30. Firebase多張圖片
你想讓它們在一張桌子上,一個網格上,隨機地隨着蝴蝶在它們之間飛舞嗎?你需要提供更多的上下文。 – 2011-02-03 11:24:24