I want to fill in all properties of object myRule based class MRule, I create a several activities to do it, an Activity to pass name and enabled, an Activity to pass onlyNumberList, exceptNumberList, etc... and use Back and Next button to switch different Activity.
Because Intent.putExtra can't pass object, so I plan to create a public static object staticMRule as shared var among with activities, is it OK?
And , is there the more better way?
Public static MRule staticMRule;
public class MRule {
public int ruleID;
public String name;
public Boolean enabled;
public IncomingType incomingType;
public List<String> onlyNumberList;
public List<String> exceptNumberList;
public List<String> receiverNumberList; //短信转发到的号码
public MRule(){
onlyNumberList=new ArrayList<String>();
exceptNumberList=new ArrayList<String>();
receiverNumberList=new ArrayList<String>();
}
}
public class activity1 extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity1);
Button btnNext = (Button) findViewById(R.id.btnClose);
btnNext.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
staticMRule.name="a";
}
});
}
}
public class activity2 extends Activity{
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity2);
Button btnNext = (Button) findViewById(R.id.btnClose);
btnNext.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
staticMRule.enabled=false;
}
});
}
}