Using ViewFipper in android

后端 未结 1 1085
难免孤独
难免孤独 2021-02-06 19:37

I need to create a question wizard with the help of ViewFlipper so that users can navigate between the questions easily. I need to dynamically generate the views for each questi

1条回答
  •  旧时难觅i
    2021-02-06 20:18

    What I would do in your position:

    • Make my own view class that takes as parameter what is needed to get initialised with the current question
    • Implement the ViewSwitcher.ViewFactory interface in the Activity in order to build the view for the next or previous question
    • Use a ViewSwitcher widget to allow you to switch from a question to another

    There are quite a lot of examples on how to use the ImageSwitcher widget (starting with this one). You just need to adapt them to a more general ViewSwitcher.

    The good thing about that solution over the ViewFlipper one is that you won't have to worry about memory when your quizz has 100 questions and you need to create all 100 views corresponding to your questions.

    0 讨论(0)
提交回复
热议问题