如何访问收集的数据

如何访问收集的数据

本文介绍了Roman Nurik的向导寻呼机-如何访问收集的数据?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用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).

我无法访问审阅片段"中收集的数据.我在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);
            }
        }
   }
});

但是它始终为空.

推荐答案

内部 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);

如果要将数据分配回向导,请将其放在FragmentActivity中onCreate的末尾:

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);
}

键三明治:面包"来自示例,请更改适合您的内容.千万不要尝试多合一,我认为它或多或少都是一样的.

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的向导寻呼机-如何访问收集的数据?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-04 22:42