Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Viewで詳細画面を作成する #27

Open
4 tasks
github-actions bot opened this issue Apr 15, 2024 · 0 comments
Open
4 tasks

Viewで詳細画面を作成する #27

github-actions bot opened this issue Apr 15, 2024 · 0 comments
Labels
View View(XMLレイアウト)でUIを作成する課題です 任意 自由に選んで取り組める課題です。スキップも可能です。

Comments

@github-actions
Copy link

🖥️ 詳細画面を追加してメイン画面から遷移できるようにします

Note

Required(先に完了させましょう)

Next(次に取り組みましょう)

課題内容

  • 詳細画面のFragmentを追加する
  • メイン画面の「Next」ボタン押下で詳細画面に遷移する
  • メイン画面で表示していた都市名を詳細画面でも表示する
  • 戻るボタン押下でメイン画面に戻る

詳細画面のレイアウト

以下の条件を満たす範囲で自由にレイアウトを組んでください

  • 地点名を表記する
  • 天気予報を3時間ごとにリスト表示する

Tip

リスト表示にはRecyclerViewもしくはListViewを利用します

image

リストの各要素に表示する

  • 日時
  • 天気アイコン
  • 気温

image

Fragmentの画面遷移

Fragmentを追加したり、移動するにはFragmentManagerを利用します。戻るボタンで元の画面に遷移できよう、BackStackにトランザクションを積んでおきましょう。

Fragmentに引数を渡す

Warning

Fragmentのコンストラクタに引数を渡す方法は正しく動作しない場合があります。Activity同様にFragmentもAndroidシステムによって破棄&再生成される場合がありますが、再生成時は引数なしコンストラクタが呼ばれるためデータが失われてしまいます😰

代わりにBundleを利用します

val fragment = YourFragment().apply {
    arguments = bundleOf(
         "key" to "value",
    )
}

完成イメージ

天気予報のリスト表示は空もしくはダミーデータで大丈夫です

image

参考資料

@github-actions github-actions bot added View View(XMLレイアウト)でUIを作成する課題です 任意 自由に選んで取り組める課題です。スキップも可能です。 labels Apr 15, 2024
@github-actions github-actions bot added this to the 6. 詳細画面の作成 milestone Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
View View(XMLレイアウト)でUIを作成する課題です 任意 自由に選んで取り組める課題です。スキップも可能です。
Projects
None yet
Development

No branches or pull requests

0 participants