PagerSwitch tab样式加下拉刷新(二)

这次总结下拉刷新

以这个为例子吧。

先写列表的model和adapter.


model多独立写写,写多了就熟练了。

public class MyorderReceiveInfo implements Serializable {

	private int id;
	
	private String logo;
	
	private String subname;
	private String smallname;
	private int rating;
	private String price;
	private String pay;
	private String receive;

	
	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getLogo() {
		return logo;
	}

	public void setLogo(String logo) {
		this.logo = logo;
	}

	public String getSubname() {
		return subname;
	}

	public void setSubname(String subname) {
		this.subname = subname;
	}

	public String getSmallname() {
		return smallname;
	}

	public void setSmallname(String smallname) {
		this.smallname = smallname;
	}
	public int getRating() {
		return rating;
	}

	public void setRating(int rating) {
		this.rating = rating;
	}

	public String getPrice() {
		return price;
	}

	public void setPay(String pay) {
		this.pay = pay;
	}

	public String getPay() {
		return pay;
	}

	public void setReceive(String receive) {
		this.receive = receive;
	}
	
	public String getReceive()
	{
		return receive;
	}
	
	
	public MyorderReceiveInfo(String subname,String smallname, int rating, String price,String pay,String receive) {
		super();
		this.subname = subname;
		this.smallname = smallname;
		this.rating = rating;
		this.price = price;
		this.pay = pay;
		this.receive = receive;
	}

	public static List<MyorderReceiveInfo> getTest(){
		List<MyorderReceiveInfo> list = new ArrayList<MyorderReceiveInfo>();
		MyorderReceiveInfo test1 = new MyorderReceiveInfo("科目二","向师傅", 3, "3000元", "待接收","接收");
		MyorderReceiveInfo test2 = new MyorderReceiveInfo("科目一","向师傅", 3, "3000元", "已接收","接收");
		MyorderReceiveInfo test3 = new MyorderReceiveInfo("科目三","向师傅", 3, "3000元", "待接收","接收");
		
		list.add(test1);
		list.add(test2);
		list.add(test3);
		return list;
	}
}


Adapter也比较常规格式,但是里面要注意的细节比较多。刚接触的时候写了好多遍


public class MyorderReceiveAdapter extends BaseAdapter{

	private List<MyorderReceiveInfo> mMyorderList;
	private LayoutInflater minflater;
	// Context context;
	 public MyorderReceiveAdapter(Context context, List<MyorderReceiveInfo> myorderList)
	 {
		 mMyorderList = myorderList;
		 minflater = LayoutInflater.from(context);
		 //this.context = context;
	 }
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		if(mMyorderList == null)
		{
			return 0;
		}else
		{
			return mMyorderList.size();
		}
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		return null;
	}

	@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
		ViewHolder holder = null;
		if(convertView == null)
		{
			holder = new ViewHolder();
		
			convertView = minflater.inflate(R.layout.myorderreceive_item, null);		
			//convertView = minflater.inflate(R.layout.myorder_item, null);
			holder.tv_subname = (TextView)convertView.findViewById(R.id.tv_bname);
			holder.tv_sname = (TextView)convertView.findViewById(R.id.tv_sname);
			holder.tv_price = (TextView)convertView.findViewById(R.id.tv_price);
			holder.tv_pay = (TextView)convertView.findViewById(R.id.tv_pay);
			holder.bt_receive =(Button)convertView.findViewById(R.id.bt_evaluate);
			holder.rb_rating =(RatingBar)convertView.findViewById(R.id.rb_rating);
			convertView.setTag(holder);
		}
		else
		{
			holder = (ViewHolder) convertView.getTag();
		}
						
		holder.tv_subname.setText(mMyorderList.get(position).getSubname());
		holder.tv_sname.setText(mMyorderList.get(position).getSmallname());
		holder.tv_price.setText(mMyorderList.get(position).getPrice());
		holder.tv_pay.setText(mMyorderList.get(position).getPay());
		holder.rb_rating.setRating(mMyorderList.get(position).getRating());
		holder.bt_receive.setText(mMyorderList.get(position).getReceive());
		
		
		return convertView;
	}
	public class ViewHolder
	{
				
		public TextView tv_subname;
		private TextView tv_sname;
		private TextView tv_price;
		private TextView tv_pay;
		private RatingBar rb_rating;
		private Button bt_receive;
	}

}


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值