项目作者: drozdzynski

项目描述 :
Steppers view library for Android, based on Google Material design guidelines
高级语言: Java
项目地址: git://github.com/drozdzynski/Steppers.git
创建时间: 2015-12-27T18:17:52Z
项目社区:https://github.com/drozdzynski/Steppers

开源协议:

下载





Steppers

Screen

Setup

1. Add library to project

Grab via Gradle:

  1. dependencies {
  2. compile 'me.drozdzynski.library.steppers:steppers:1.0.0'
  3. }

Manual

  • Download the library folder.
  • Copy to root project folder
  • Add to your settings.gradle file the following code line: “include ‘:app’, ‘:steppers’”
  • Rebuild the project
  • Add dependency
    • File → Project Structure
    • in Modules section click on “app”
    • Click on tab “Dependecies”
    • Click on the green plus
    • Module Dependecy
    • Select “:library”
  • Done

2. Add view in XML Layout

  1. <me.drozdzynski.library.steppers.SteppersView
  2. android:id="@+id/steppersView"
  3. android:layout_width="match_parent"
  4. android:layout_height="match_parent"></me.drozdzynski.library.steppers.SteppersView>

3. Setup config for SteppersView

  1. SteppersView.Config steppersViewConfig = new SteppersView.Config();
  2. steppersViewConfig.setOnFinishAction(new OnFinishAction() {
  3. @Override
  4. public void onFinish() {
  5. // Action on last step Finish button
  6. }
  7. });
  8. steppersViewConfig.setOnCancelAction(new OnCancelAction() {
  9. @Override
  10. public void onCancel() {
  11. // Action when click cancel on one of steps
  12. }
  13. });
  14. steppersViewConfig.setOnChangeStepAction(new OnChangeStepAction() {
  15. @Override
  16. public void onChangeStep(int position, SteppersItem activeStep) {
  17. // Action when click continue on each step
  18. }
  19. });
  20. // Setup Support Fragment Manager for fragments in steps
  21. steppersViewConfig.setFragmentManager(getSupportFragmentManager());

4. Create steps list

  1. ArrayList<SteppersItem> steps = new ArrayList<>();
  2. SteppersItem stepFirst = new SteppersItem();
  3. stepFirst.setLabel("Title of step");
  4. stepFirst.setSubLabel("Subtitle of step");
  5. stepFirst.setFragment(new SomeFragment());
  6. stepFirst.setPositiveButtonEnable(false);
  7. steps.add(stepFirst);

5. Set config, list and build view;

  1. SteppersView steppersView = (SteppersView) findViewById(R.id.steppersView);
  2. steppersView.setConfig(steppersViewConfig);
  3. steppersView.setItems(steps);
  4. steppersView.build();

Other functions

Enable skip step button

Simple:

  1. item.setSkippable(true);

With callback:

  1. item.setSkippable(true, new OnSkipStepAction() {
  2. @Override
  3. public void onSkipStep() {
  4. // Some action after step is skipped
  5. }
  6. });

Override continue button

  1. item.setOnClickContinue(new OnClickContinue() {
  2. @Override
  3. public void onClick() {
  4. // Some action on click
  5. steppersView.nextStep(); // Now You must call next step
  6. }
  7. });

Change active step

  1. steppersView.setActiveItem(1); // step index from 0

Disable cancel button (hide)

  1. steppersViewConfig.setCancelAvailable(false);

License

  1. Copyright (C) 2015-2017 Krystian Drożdżyński
  2. Licensed under the Apache License, Version 2.0 (the "License");
  3. you may not use this file except in compliance with the License.
  4. You may obtain a copy of the License at
  5. http://www.apache.org/licenses/LICENSE-2.0
  6. Unless required by applicable law or agreed to in writing, software
  7. distributed under the License is distributed on an "AS IS" BASIS,
  8. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  9. See the License for the specific language governing permissions and
  10. limitations under the License.