我在阵列列表中有8个图像,我只需要将4个图像放在网格中,当我按下一个时,接下来的4个图像将显示在同一个网格中
我正在使用for循环
for (i = 0; i < 4; i++) {
ItemClassForCategoryImages itemClassForCategoryImages = new MainActivity().new ItemClassForCategoryImages();
itemClassForCategoryImages.imageId = imgesForCategories[i];
itemClassForCategoryImages.GridText = GridText[i];
data.add(itemClassForCategoryImages);
}
和另一个for循环
textViewForMoreOption.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// TODO Auto-generated method stub
data = new ArrayList<MainActivity.ItemClassForCategoryImages>();
for (j = i; j < i+4; i++) {
ItemClassForCategoryImages itemClassForCategoryImages = new MainActivity().new ItemClassForCategoryImages();
itemClassForCategoryImages.imageId = imgesForCategories[j];
itemClassForCategoryImages.GridText = GridText[j];
data.add(itemClassForCategoryImages);
i=0;
}
CustomAdapteForGrid adapter = new CustomAdapteForGrid(
BaseActivity.width, BaseActivity.height, data, ctx, 2);
gridViewForCategories.setAdapter(adapter);
}
});
但是这让我出界了。 有人能给我一个简单的方法......?