Android 开发之 GridView 网格布局使用
2010-04-12 19:07:00 来源:WEB开发网核心提示:}@Overridepublic long getItemId(int position) {// TODO Auto-generated method stubreturn position;}@Overridepublic View getView(int position, View convertView, V
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ImageView iv = new ImageView(activity);
iv.setImageResource(image[position]);
return iv;
}
}
3. 给GridView指定Adapter
Java代码
1. GridView gv = (GridView) findViewById(R.id.gride);
2.
3. ImageList adapter = new ImageList(this);
4.
5. gv.setAdapter(adapter);
GridView gv = (GridView) findViewById(R.id.gride);
ImageList adapter = new ImageList(this);
gv.setAdapter(adapter);
所以最后效果图是这样的 网格布局
更多精彩
赞助商链接