普通的跳转方法
startActivity(new Intent(IndexActivity.this, BasicNaviActivity.class));
Fragment跳转Activity
Intent intent = new Intent(getActivity(), NaviStartActivity.class);
startActivity(intent);
所有传值 都尽量在 onCreate里面写吧 有些地方会收不到
当然 一开始加载的生命周期都可以
Activity 跳转传值
Intent intent=new Intent(MainActivity.this,Activity2.class);
intent.putExtra("data1", "这里塞你要传递的值" );
intent.putExtra("data2", "这里塞你要传递的值" );//你可以多传几个 类型也有很多
startActivity(intent);
接收activity 写法
String data = getIntent().getStringExtra("data1");
String data = getIntent().getStringExtra("data2");
Activity 跳转传输list
序列化里面的所有类 都要 implements Serializable 内部的也要写上
//例
public static class SchedulingDataBean implements Serializable {
private String ProjectID;
private List ScheduleEveryDayList;
public String getProjectID() {
return ProjectID;
}
public void setProjectID(String ProjectID) {
this.ProjectID = ProjectID;
}
public List getScheduleEveryDayList() {
return ScheduleEveryDayList;
}
public void setScheduleEveryDayList(List ScheduleEveryDayList) {
this.ScheduleEveryDayList = ScheduleEveryDayList;
}
public static class ScheduleEveryDayListBean implements Serializable {
private String Is_Can_Edit="";
public String getIs_Can_Edit() {
return Is_Can_Edit;
}
public void setIs_Can_Edit(String is_Can_Edit) {
Is_Can_Edit = is_Can_Edit;
}
}
}
传递方
SchedulingDataBean bean = new SchedulingDataBean();
List listBeans = new ArrayList<>();
SchedulingDataBean.ScheduleEveryDayListBean scBean = new SchedulingDataBean.ScheduleEveryDayListBean();
bean.setProjectID("需要传的内容");
scBean.setIs_Can_Edit("子类需要传递的东西");
listBeans.add(scBean);
bean.setScheduleEveryDayList(listBeans);
Intent intent = new Intent(DataInsidePagesActivity.this, ComplaintActivity.class);
intent.putExtra("SchedulingDataBeanList", (Serializable) bean);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
接受方
String data = getIntent().getSerializableExtra("SchedulingDataBeanList");
DataInsidePagesBean schedulingDataBean = gson.fromJson(data, SchedulingDataBean.class);//转一下 然后看着取值用吧