我正在添加一個ImageView
s的數組,並動態地爲每個ImageView
設置一個圖像,我完成了它。但問題是如何設置/定義onClicklistener方法在ImageView
?如何在Android中設置ImageView的onClicklistener方法?
這裏是我的代碼:
ImageView[] mImages;
int[] images={R.drawable.sandle_icon1, R.drawable.sandle_icon2,
R.drawable.sandle_icon3, R.drawable.sandle_icon4};
LinearLayout ll = new LinearLayout(this);
mScrollViewImage.removeAllViews();
ll.setOrientation(LinearLayout.VERTICAL);
mImages = new ImageView[images.length];
mScrollViewImage.addView(ll);
for (floop = 0; floop < sandleicon.length; floop++) {
mImages[floop] = new ImageView(this);
mImages[floop].setImageResource(images[floop]);
ll.addView(mImages[floop]);
}
任何幫助將不勝感激。
您好迪帕克.... u必須創建ImageView的整型數組... Mitesh耆那教SKP –
我已經創建整數數組。 –