I'm trying to use Roman Nurik's WizardPager library to add and edit a custom object but I'm having troubles to assign data to certain pages (I guess I'll struggle to access the data once ready to save it as well). I don't get the concept of findByKey() and cannot assign data to pages located "underneath" a BranchPage.
Example:
My wizard model looks like this:
protected PageList onNewRootPageList() {
return new PageList(
new CustomerInfoPage(this, "Page 1"),
new BranchPage(this, "Branch page")
.addBranch("Alternative 1", new SingleFixedChoicePage(this, "Page 2.1"))
.addBranch("Alternative 2", new CustomerInfoPage(this, "Page 2.2"))
);
}
Assigning data to the first page works fine using the code below in MainActivity.java. (Thanks to Allen Chan's answer here).
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.wizard_main);
...
Bundle data = new Bundle();
if (!TextUtils.isEmpty(CustomerInfoPage.MY_DATA_KEY)) {
data.putString(CustomerInfoPage.MY_DATA_KEY, person.getName());
mWizardModel.findByKey("Page 1").resetData(data);
}
But how to assign data to the second CustomerInfoPage acting as a sub-page to the BranchPage? I've tried all sort of keys like
mWizardModel.findByKey("Branch page:Page 2.2").resetData(data);
but without luck. Everything I've tried causes NullPointerException on that particular row.
Please advice - thanks in advance!