【问题标题】:How to skip a WizardStep in WizarDroid如何在 WizarDroid 中跳过 WizardStep
【发布时间】:2014-07-18 10:33:27
【问题描述】:

我使用 WizarDroid,如果满足某些条件,我打算跳过一个步骤。

我有以下流程:

flow = new WizardFlow.Builder()
      .setActivity(this)                      //First, set the hosting activity for the wizard
      .setContainerId(R.id.step_container)    //then set the layout container for the steps.
      .addStep(WStep1.class)                   //Add your steps in the order you want them
      .addStep(WStep2.class)                  //to appear and eventually call create()
      .addStep(WStep3.class)                 //to create the wizard flow.
      .create();

如果设置了变量,我打算跳过 WStep2。

根据它的教程,我只能禁用前进到下一步,直到我设置它:Controlling wizard flow dynamically

如何告诉向导可以跳过下一步?

【问题讨论】:

    标签: android wizard


    【解决方案1】:

    WizarDroid 似乎不提供从 WizardFlow 中删除步骤的功能。

    但是,您可以检查您在WStep2 中提到的变量,然后调用goNext()。这肯定会奏效。

    如果你想尝试另一种方式,你也可以使用(虽然我不能保证它会起作用):

    setStepCompleted(1, true) //setStepCompleted(int stepPosition, boolean stepCompleted)
    

    编辑:看到您还想在向导中倒退,您必须拆分向导。

    我的意思是,如果你想在某些情况下跳过 WStep3:

    在你的 MainActivity.class 中

    flow1 = new WizardFlow.Builder()
          .setActivity(this)
          .setContainerId(R.id.step_container)
          .addStep(WStep1.class)
          .addStep(WStep2.class)
          .create();
    

    在 WStep2.class 中

    if (skipWStep3()){
        flow2 = new WizardFlow.Builder()
                  .setActivity(this)
                  .setContainerId(R.id.step_container)
                  .addStep(WStep4.class)
                  .addStep(WStep5.class)
              .create();
    }
    else {
        flow2 = new WizardFlow.Builder()
                  .setActivity(this)
                  .setContainerId(R.id.step_container)
                  .addStep(WStep3.class)
                  .addStep(WStep4.class)
                  .addStep(WStep5.class)
              .create();
    }
    

    【讨论】:

    • 应该在哪个方法中调用goNext?我试图在“onCreate”中调用“完成”,它似乎跳过了它,但是当我使用“后退”按钮时,它会返回到“隐藏”页面。
    • 所以你想前进和后退......使用WizarDroid,看起来你采取了不同的方法。我只是编辑答案
    【解决方案2】:

    BasicWizardLayout 默认不支持跳过步骤。您必须对其进行子类化并使用 API 方法 Wizard#setCurrentStep,或者按照 here 的说明通过子类化 WizardFragment 来编写自己的向导布局类。

    void org.codepond.wizardroid.Wizard.setCurrentStep ( int 步位置)

    设置向导的当前步骤

    参数

    stepPosition the position of the step within the WizardFlow
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-04-25
      • 2012-02-09
      • 2017-07-26
      • 2020-06-02
      • 2018-04-24
      相关资源
      最近更新 更多