在这里,我有 17 张图像,我想使用Grid Layout
但 on getview()
call 方法在活动中显示这些(连续 2 张图像)。
如何设置单个活动中的图像数量限制。
public View getView(int position, View convertView, ViewGroup parent)
{
ViewHolder holder = null;
RowData rowData=null;
rowData = getItem(TabbedHorizontalPagerDemo.startWith);
if(convertView == null) {
convertView = mInflater.inflate(R.layout.list, null);
holder = new ViewHolder(convertView);
convertView.setTag(holder);
}
holder = (ViewHolder) convertView.getTag();
ImageView imageView1 = holder.getImage();
imageView1.setImageResource(rowData.mImgid);
TextView textView1 = holder.getTextView();
textView1.setText(rowData.mTitle);
TabbedHorizontalPagerDemo.startWith++;
return convertView;
}
/*
* Class to get values from a single row of list view
*/
private class ViewHolder
{
private View mRow;
private TextView textView = null;
private ImageView image = null;
public ViewHolder(View row){
mRow = row;
}
public ImageView getImage(){
if(image == null)
image = (ImageView) mRow.findViewById(R.id.imageView1);
return image;
}
public TextView getTextView(){
if(textView == null)
textView = (TextView) mRow.findViewById(R.id.imgText);
return textView;
}
}