Android开发中,用到的界面之间数据传值方法:

Intent intent = new Intent(this,SecondActivity.class);

        //方法一:
        String title = "我是来自第一个界面";

        intent.putExtra("string_name",title);

        //方法二
        SecondBean bean = new SecondBean();
        bean.setAge(18);
        bean.setName("FlyToSky");

        Bundle bundle = new Bundle();
        bundle.putSerializable("bean",bean);
        intent.putExtra("bundle",bundle);

        startActivity(intent);

获取值:

Intent intent = getIntent();

        //方法一
        String title = intent.getStringExtra("string_name");

        //方法二
        SecondBean bean = (SecondBean) intent.getBundleExtra("bundle").getSerializable("bean");

注意:对于传值的实体类,需要实现 Serializable,代码如下:

public class SecondBean implements Serializable {
    private int age;
    private String name;

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}