2011-12-02 92 views
1

爲我的圖庫設置了多個圖像後,我想獲取所有已使用的資源ID。 如何獲取圖庫中ImageView的圖像資源(int)?ImageView的圖像資源

謝謝。

+0

第一的你是如何設置的圖像顯示一些代碼。 –

+0

你能多解釋一下嗎? – Sameer

回答

-1
public class IndexImageAdapter extends BaseAdapter { 

private Context context; 
private int[] panicBuyingImages = {R.drawable.q1 , R.drawable.q2 , R.drawable.q3 , R.drawable.q4}; 
public IndexImageAdapter(Context context){ 
    this.context = context; 
} 

public int getCount(){ 
    return Integer.MAX_VALUE; 
} 

public Object getItem(int arg0){ 
    return arg0; 
} 

public long getItemId(int position){ 
    return position; 
} 

public View getView(int position, View convertView, ViewGroup parent) { 
    ImageView i = new ImageView(this.context); 
    i.setImageResource(this.panicBuyingImages[position % panicBuyingImages.length]); 
    i.setScaleType(ImageView.ScaleType.FIT_XY); 
    i.setLayoutParams(new Gallery.LayoutParams(140, 140)); 
    return i; 
} 

}