This is the new shit

package com.example.sax;
 
import java.util.ArrayList;
  
public class MySaxHandler {
     
    private ArrayList<Beauty> mList = new ArrayList<Beauty>();
    private Beauty beauty = new Beauty();
     
    public void andy(){
            beauty.setName("杨幂");
            beauty.setAge("18");
            mList.add(beauty);
        }
    
   public void setmList(ArrayList<Beauty> list){
       this.mList = list;
   }
   
}

  

package com.example.sax;
 
public class Beauty {
      
    private String name;
    private String age;
  
    public void setName(String name) {
        this.name = name;
    }
  
    public void setAge(String age) {
        this.age = age;
    }
  
    public String toString() {
        return "美女资料 [年龄=" + age + ", 姓名=" + name + "]";
    }
}

  

package com.example.sax;
 
import java.util.ArrayList;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;
  
public class MainActivity extends Activity{
     
	public ArrayList<Beauty> beautyList = new ArrayList<Beauty>();
     
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        doMyMission();
        setupViews();
    }
     
    public void doMyMission(){
            MySaxHandler msh = new MySaxHandler();
            msh.setmList(beautyList);
            msh.andy();
    }
     
    public void setupViews(){
        String result = "";
        for (Beauty b : beautyList) { 
            result += b.toString(); 
        } 
        TextView textView = (TextView) findViewById(R.id.textView); 
        textView.setText(result);
    }
}

  

猜你喜欢

转载自www.cnblogs.com/cuthead/p/thisisthenewshit.html
new