以下是baseadapter文件
public class MyBaseadapter extends BaseAdapter{
private Context context;
private List<User>data; public MyBaseadapter(Context content, List<User> data) {
super();
this.context = content;
this.data = data;
} public int getCount() {
// TODO Auto-generated method stub
return data.size();
} public Object getItem(int position) {
// TODO Auto-generated method stub
return data.get(position);
} public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
} public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View view =LayoutInflater.from(context).inflate(R.layout.galleryitem, null);
User user=data.get(position);
ImageView iv=(ImageView) view.findViewById(R.id.gallery_touxiang);
iv.setImageResource(user.getTouxiang());
return view;
}}
public class MyBaseadapter extends BaseAdapter{
private Context context;
private List<User>data; public MyBaseadapter(Context content, List<User> data) {
super();
this.context = content;
this.data = data;
} public int getCount() {
// TODO Auto-generated method stub
return data.size();
} public Object getItem(int position) {
// TODO Auto-generated method stub
return data.get(position);
} public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
} public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View view =LayoutInflater.from(context).inflate(R.layout.galleryitem, null);
User user=data.get(position);
ImageView iv=(ImageView) view.findViewById(R.id.gallery_touxiang);
iv.setImageResource(user.getTouxiang());
return view;
}}
解决方案 »
- 真机器机器上测试得不到经纬度
- listview item拖动到listview以外的区域。
- Gallery组件的传统用法,显示的图片超过三个就会报错,求教
- Android的几个很基本问题。100分送上!!
- 下面这段代码如何改成对应的类?
- 求助:为什么Android应用异常后会自动重启?
- cocos2d-x cygwin编译sh文件后无法产生安卓项目
- Android 如何在程序进入后台关闭?
- android怎样在按back键退出activity时候做出侧滑的动画效果?
- ListView不显示数据,切换一次tab才显示数据
- ListView中如何添加不同布局的item?
- 不科学啊!Canvas使用了矩阵变换后使用drawVertices,保存的view还是原图而不是变换后的图,等好人ing.....
gallery.setAdapter(baseadapter);空指针