馬上加入Android 台灣中文網,立即免費下載應用遊戲。
您需要 登錄 才可以下載或查看,沒有帳號?註冊
x
小弟實做不是很豐富,因此在這裡遇到一個難題,
現在正在設計一個相簿式的APP
而在Activity中使用了Gridview來呈現assets裡面的圖片庫。
而希望點擊圖片後,會先有一個自定義Dialog來給使用者做最後決定是否要進入此圖對應的Activity及layout
並且在Dialog上附有點擊之放大圖片(有預設製作另一份大圖版)
但我不曉得如何在Activity設置layout中image的id做切換..
在此附上我的Activity code:
這邊是ImageAdapter Activity code:
- 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(180, 254));
- 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.t1, R.drawable.t2,
- R.drawable.t3, R.drawable.t4,
- R.drawable.t5, R.drawable.t6,
- R.drawable.t1, R.drawable.t2,
- R.drawable.t3, R.drawable.t4,
- R.drawable.t5, R.drawable.t6,
- R.drawable.t1, R.drawable.t2,
- R.drawable.t3, R.drawable.t4,
- R.drawable.t5, R.drawable.t6,
- };
- }
複製代碼
各位高手大大誰能幫忙我解決問題嗎?
謝謝~~ |