2011-09-23 65 views

回答

1

爲什麼你不能使用正常的ImageView?這樣做:

ArrayList<Integer> picList = new ArrayList<Integer>(); 
// populate the list with the int value of the pictures in drawable. 
picList.add(R.drawable.apple); 
picList.add(R.drawable.horse); 
//etc 
int touches = 0; 
int loop = 0; 
ImageView picture = (ImageView) findViewById(R.id.your_picture); 
picture.setOnClickListener(new View.OnClickListener() { 

     @Override 
     public void onClick(View v) { 
      if (touches < 4) 
       v.setBackgroundDrawable(picList.get(touches)); 
       touches++; 
      } else { 
       touches = 0; 
       loop = 1; 
       v.setBackgroundDrawable(picList.get(touches)); 
      } 
      if (loop = 1){ 
      // Create a TextView and set the text or make it in the xml with Visible="Gone" and make is visible here. 
      } 
    }); 
+0

你有更多的樣本或完成的樣本來測試? =) – merrill

+0

我剛剛爲你做了這個?這不是樣本。你不能讓它工作嗎? –

1

您需要創建自定義類,它擴展ImageView現在將此圖像視圖顯示到整個屏幕。

> First store the path/location of images into an array/list etc. 
> In custom class implement the onTouch event. 
> create the counter object in this custom class. 
> now in onTouch check in down event that check the counter value with array size if counter==array.length()-1 then set counter as 0 otherwise increment in counter object. 
> now get the path of the image and set into the imageview as background 
+0

你可以給我他們的樣本嗎? =) – merrill