public class MyAdapteforOwner extends BaseAdapter{
List<OwnerDevice>datas;
private Context context;
Activity activity;
//这里传入一个datas和context即可
public MyAdapteforOwner(List<OwnerDevice> datas, Context context, Activity activity) {
this.datas = datas;
this.context = context;
this.activity=activity;
} @Override
public int getCount() {
return datas.size();
}
@Override
public Object getItem(int position) {
return datas.get(position);
} @Override
public long getItemId(int position) {
return position;
} @Override
public View getView(int position, View convertView, ViewGroup parent) {
ViewHolder holder=null;
if(convertView==null){
convertView=View.inflate(context,R.layout.owneritem_layout,null);
holder=new ViewHolder();
holder.textView1= (TextView) convertView.findViewById(R.id.bts_name);
holder.textView2= (TextView) convertView.findViewById(R.id.text1);
holder.textView3= (TextView) convertView.findViewById(R.id.text2);
holder.textViewdetail= (TextView) convertView.findViewById(R.id.text_detail);
holder.textViewmap= (TextView) convertView.findViewById(R.id.text_map);
convertView.setTag(holder);
}else{
holder= (ViewHolder) convertView.getTag();
}
OwnerDevice ownerDevice=datas.get(position);
String bts_name=ownerDevice.getBts_name(); holder.textView1.setText(bts_name);
holder.textView2.setText("地址: "+ownerDevice.getAddress());
holder.textView3.setText("状态:"+ownerDevice.getAl_accountIdRepair());
//实现子控件监听,在adapter里面写监听事件
holder.textViewmap.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//点击查看地图实现方法
//t跳转页面需要有context调用startActivity
Intent intent=new Intent((Activity)context, Map_Activity.class);
((Activity)context).startActivity(intent);
}
}); holder.textViewdetail.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) { }
});
return convertView;
}
class ViewHolder{
TextView textView1 ,textView2,textView3;
TextView textViewmap,textViewdetail; }
}

最新文章

  1. 关系型数据库与NoSQL数据库
  2. SQLite学习笔记(十二)&amp;&amp;虚拟机指令
  3. 用VB实现SmartQQ机器人
  4. Unix调试工具dbx使用方法
  5. Java中“==”与equals方法的区别
  6. 使用Discuz关键词服务器实现PHP中文分词
  7. Android EditText边框颜色的selector 使用focus标记当前填写的框
  8. 如何让centos6.5在vm11里上网,连接网络?
  9. 【细说Java】方法重载的简单介绍
  10. SPA 单页面应用
  11. 转:JMeter进行Java 请求测试
  12. web&mdash;URL不同形式地址的问题
  13. Algorithm --&gt; 判读是否是子树
  14. java的集合:List、Set和Map
  15. JavaScript视频分享,学无止境。
  16. 简单的TSQL基础编程格式,存储过程,视图
  17. 查询rman 备份信息集
  18. opencv入门指南(转载)
  19. python的sciter库Pysciter安装教程(win32 + win64)
  20. Python练习-基于socket的FTPServer

热门文章

  1. Swift - what&#39;s the difference between metatype .Type and .self?
  2. In-Out Parameters inout keyword
  3. Java中的自动转换
  4. Django01 web http 基础
  5. A*寻路算法详解
  6. Python可视化数据------seaborn
  7. int rc = -EINVAL是什么意思
  8. 在asyncio 中跳出正在执行的task
  9. 【BZOJ3600】没有人的算术 - 替罪羊树+线段树
  10. 51nod-独木舟问题