Roman Nurik 的向导寻呼机 - 如何访问收集的数据? [英] Roman Nurik's Wizard pager - how to access collected data?
问题描述
我正在尝试使用 Roman Nurik 的库制作一个向导 (https://plus.google.com/113735310430199015092/posts/6cVymZvn3f4).
I am trying to make a wizard using Roman Nurik's library (https://plus.google.com/113735310430199015092/posts/6cVymZvn3f4).
我无法访问从 Review Fragment 收集的数据.我在 ReviewFragment 中公开了 mCurrentReviewItems 然后我像这样尝试了
I am having trouble accessing the collected data from the Review Fragment. I made mCurrentReviewItems public in ReviewFragment and then I tried it like this
mNextButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mPager.getCurrentItem() == mCurrentPageSequence.size()) {
ReviewFragment reviewFragment = (ReviewFragment) mPagerAdapter.getItem(mPager.getCurrentItem());
for (ReviewItem item : reviewFragment.mCurrentReviewItems)
Log.d(MainActivity.TAG, "Item: " + item.getDisplayValue());
}
} else {
if (mEditingAfterReview) {
mPager.setCurrentItem(mPagerAdapter.getCount() - 1);
} else {
mPager.setCurrentItem(mPager.getCurrentItem() + 1);
}
}
}
});
然而它总是为空.
推荐答案
Inside if (mPager.getCurrentItem() == mCurrentPageSequence.size()) { }
对于单页变量:
String data = mWizardModel.findByKey("Sandwich:Bread").getData().getString(Page.SIMPLE_DATA_KEY);
对于自定义页面:
String data =
mWizardModel.findByKey(THE_KEY).getData().getString(CustomerInfoPage.YOUR_DATA_KEY);
如果要将数据分配回向导,请将其放在 onCreate 末尾的 FragmentActivity 中:
If you want to assign the data back to the wizard, put this at the end of onCreate in FragmentActivity:
Bundle data = new Bundle();
if (!TextUtils.isEmpty(DATA_STRING)) {
data.putString(Page.SIMPLE_DATA_KEY, DATA_STRING);
mWizardModel.findByKey("Sandwich:Bread"").resetData(data);
}
关键三明治:面包"来自示例,更改适合您的任何内容.千万不要尝试multi one,我认为它或多或少是一样的.
The key "Sandwich:Bread" is from the example, change whatever suit you. Never try the multi one, I think it is more or less the same.
这篇关于Roman Nurik 的向导寻呼机 - 如何访问收集的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!