0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

Android Studio: Navigation Drawer Views Activity を使う

Last updated at Posted at 2023-09-30

テンプレート Navigation Drawer Views Activity を使います。
image.png

このままでは、Build ができません。

build.gradle.kts を修正します。

33 -> 34
image.png

build.gradle.kts
(省略)
compileSdk = 34
(省略)
targetSdk = 34
(省略)

res -> values -> strings.xml の修正

image.png

res/values/strings.xml
<resources>
    <string name="app_name">example05</string>
    <string name="navigation_drawer_open">Open navigation drawer</string>
    <string name="navigation_drawer_close">Close navigation drawer</string>
    <string name="nav_header_title">Android Studio</string>
    <string name="nav_header_subtitle">android.studio@android.com</string>
    <string name="nav_header_desc">Navigation header</string>
    <string name="action_settings">Settings</string>

    <string name="menu_home">ホーム</string>
    <string name="menu_gallery">ギャラリー</string>
    <string name="menu_slideshow">スライドショー</string>
</resources>

java -> com.example.example05 -> ui の修正

gallery -> GalleryViewModel
image.png

value = "これはギャラリーです。"

home -> HomeViewModel
image.png

value = "これはホームです。"

slideshow -> SlideshowViewModel
image.png

value = "これはスライドショーです。"

Run

image.png

image.png

image.png

実機での動作確認

app-debug.apk を USB 経由で、アンドロイドタブレットに持っていきます。

image.png

実行時の様子
android02.png

0
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
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?