WEB开发网
开发学院手机开发Android 开发 Android GridView 网格布局 使用 阅读

Android GridView 网格布局 使用

 2010-08-26 00:17:00 来源:WEB开发网   
核心提示:用于显示目标ImageViewJava代码public class ImageList extends BaseAdapter {Activity activity;//constructpublic ImageList(Activity a ) {activity = a;}@Overridepublic int g

用于显示目标ImageView

Java代码

public class ImageList extends BaseAdapter {

Activity activity;

//construct

public ImageList(Activity a ) {

activity = a;

}

@Override

public int getCount() {

// TODO Auto-generated method stub

return image.length;

}

@Override

public Object getItem(int position) {

// TODO Auto-generated method stub

return image[position];

}

@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;

}

}

public class ImageList extends BaseAdapter {

Activity activity;

//construct

public ImageList(Activity a ) {

activity = a;

}

@Override

public int getCount() {

// TODO Auto-generated method stub

return image.length;

}

@Override

public Object getItem(int position) {

// TODO Auto-generated method stub

return image[position];

}

@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;

}

Tags:Android GridView 网格

编辑录入:coldstar [复制链接] [打 印]
赞助商链接