package www.wulian1.com.webview; import android.app.Activity;import android.view.View;import android.view.ViewGroup;import android.widget.BaseAdapter;import android.widget.TextView; import java.util.List; /** * Created by Administrator on 2017/5/18. */public class MyAdapter extends BaseAdapter { public List<StuManage> stuList; public Activity activity; public MyAdapter(List<StuManage> stuList,Activity activity){ this.stuList=stuList; this.activity=activity; } public void setList(List<StuManage> stuList) { this.stuList=stuList; } @Override public int getCount() { return this.stuList.size(); } @Override public Object getItem(int position) { return this.stuList.get(position); } @Override public long getItemId(int position) { return position; } @Override public View getView(int position, View view, ViewGroup parent) { /*View view1=activity.getLayoutInflater().inflate(R.layout.adapter_item,null); TextView textView=(TextView)view.findViewById(R.id.tv_age) ; TextView textView1=(TextView)view.findViewById(R.id.tv_name) ; textView.setText(this.stuList.get(position).getAge()+""); textView1.setText(this.stuList.get(position).getName()); return view;*/ View view1=activity.getLayoutInflater().inflate(R.layout.adapter_item,null); TextView textView1= (TextView) view1.findViewById(R.id.tv_name); TextView textView2= (TextView) view1.findViewById(R.id.tv_age); textView1.setText(stuList.get(position).getName()); textView2.setText(stuList.get(position).getAge()+""); return view1; }}
时间: 2024-10-12 13:38:04