LoginSignup
1
1

More than 5 years have passed since last update.

即売会サービスを作ろう6

Posted at

今回はUIとシーン管理機能を作ります。

シーン管理について

シーンとはショップ画面、メニュー画面等、遷移することがある画面のことをさしていて、
切り替えはActivityでなくViewで行い、これらシーン階層を操作するクラス(SceneManager https://gist.github.com/nagai/11076564 )を作りました。

このクラスはActivity内に存在しているViewAnimatorを操作するクラスです。

public class MenuActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_menu);

        // アプリ全体で一つ SceneManager を取得する
        CustomApplication app = CustomApplication.getInstance();
        SceneManager manager = app.getSceneManager();

        // このActivity 内で遷移するようにする。 id は ViewAnimator のID
        manager.setup(this,R.id.flipper);
        // シーンを切り替える
        manager.change( new S030menu() );
    }
}

このような形で activityごとに初期化をして

CustomApplication app = CustomApplication.getInstance();
app.getSceneManager().push( new S040circlemenu(), SceneManager.Animation.LeftScroll );

切り替えたいシーンはpush、戻る場合はpopを呼び出すことで実現しています。

まとめ

そんな感じで本日の作業はこちら
https://github.com/nagai/freemarket/tree/20140419
次はサークル登録通信処理を作ります。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1