开发者

Right implementation choice for switching 20+ different screens

I'm making a quiz-like game, where user answers each question before they are allowed to go to the next one.

Characteristics of my app:

  • Each session will have around 10-30 screens.
  • In general, the screens are het开发者_高级运维erogenious in layout structures, but they can be classified into 5-6 types.
  • The expected time that user interacts with each screen is 10-30 seconds
  • Once user goes to the next screen, the previous one is not needed anymore (he never goes back)
  • I want to have a nice sliding transition animation when going from one screen to the next

Implementations I'm considering:

  1. Start a new Activity for each screen in the 'forwarding' style, i.e. start the next screen then finish the current one.
  2. Load all the views before hand and use ViewAnimator

It looks like none of my current solution is good. Can you help me on a solution that is good in terms of memory consumption, battery consumption, and responsiveness?

Thank you very much.


OK below is what I did. It turned out I manually set the animation

onCreate() {
    mAnimation = AnimationUtils.loadAnimation(getApplicationContext(), R.anim.slide_in_right);
    mViewPool = new View[] { /* A few views for re-using, each of different type */ };
}

proceed() {
    nextView = getView(type);
    mFrame.removeAllChilds();
    mFrame.addView(nextView);
    nextView.startAnimation(mAnimation);
}

getView(int type) {
    View view = mViewPool[type];
    // reset some subviews if neccessary
    return view;
}

Where mFrame is whatever ViewGroup you think is appropriate, not neccessarily ViewAnimator. Mine happens to be ScrollView.

If you see any potential problem with this approach, please let me know. Many thanks.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜