MyAdapter.java

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了MyAdapter.java相关的知识,希望对你有一定的参考价值。

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






















































以上是关于MyAdapter.java的主要内容,如果未能解决你的问题,请参考以下文章