zoukankan      html  css  js  c++  java
  • 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;
    	}
    
    }

    
  • 相关阅读:
    架构设计:负载均衡层设计方案(4)——LVS原理
    架构设计:负载均衡层设计方案(3)——Nginx进阶
    架构设计:负载均衡层设计方案(2)——Nginx安装
    架构设计:负载均衡层设计方案(1)——负载场景和解决方式
    oracle 触发器number判断空值,:NEW赋值,for each row,sql变量引号,to_date,to_char
    oracle触发器调试
    if elsif;报错;new赋值
    求一行的和
    oracle如何获取当年第一月,如今年是2015年,则需获取 201501
    在其他对象上同步
  • 原文地址:https://www.cnblogs.com/peterleee/p/9373788.html
Copyright © 2011-2022 走看看