开发者

Android wizard-like (step by step) application

开发者 https://www.devze.com 2023-02-14 06:36 出处:网络
I\'d like to build an android step application so I can go back and forth between activities. I\'d like to create a base class for the step manager that includes two buttons to go forward and back, s

I'd like to build an android step application so I can go back and forth between activities.

I'd like to create a base class for the step manager that includes two buttons to go forward and back, so in the child activities I don't have to recreate those controls every time. The step manager class has to take care of the switching between activities in a precise order and of passing data between them.

I tried to write some code but I can't merge the parent's layout with the child one!

FrameLayout fl = (FrameLayout)this.findViewById(R.id.frame);

LayoutInflater.from(this).inflate(rId, fl, true);

This code is in the parent class (inherited from Activity):

  • the FrameLayout is开发者_如何学Python the place holder for the child-layout controls;
  • rId is the layout resource ID of a LinearLayout in the child xml layout.

I guess that the problem about that code is that I don't call the setContentView of the child layout, so anytime I use the findViewById of a child control I get a null pointer.

What is the best practice to create something like that?

Thanks, Simone.


You can use a single activity thus avoiding passing data between them and saving memory.
In this activity you can use a ViewSwitcher or (better) a ViewFlipper to let the user navigate between steps.

0

精彩评论

暂无评论...
验证码 换一张
取 消