質問編集履歴

1

解決

2022/01/24 15:42

投稿

iceE
iceE

スコア25

test CHANGED
File without changes
test CHANGED
@@ -3,56 +3,5 @@
3
3
  右側のFragmentはincludeで配置し、左側のMainFragmentはNavHostFragmentを配置して、NavigationGraphで画面遷移をしようと考えています。
4
4
  そこで、左側に配置したMenuのボタンをクリックしたときにMainFragmentを画面遷移させるにはどうすればよいでしょうか?
5
5
 
6
- ### 該当のソースコード
7
- ```xml
8
- <?xml version="1.0" encoding="utf-8"?>
9
- <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
10
- xmlns:app="http://schemas.android.com/apk/res-auto"
11
- xmlns:tools="http://schemas.android.com/tools"
12
- android:layout_width="match_parent"
13
- android:layout_height="match_parent"
14
- tools:context=".MainActivity">
15
-
16
- <LinearLayout
17
- android:layout_width="match_parent"
18
- android:layout_height="match_parent"
19
- android:layout_weight="8"
20
- android:orientation="vertical"
21
- android:background="@color/MenuColor">
22
-
23
- <LinearLayout
24
- android:layout_width="match_parent"
25
- android:layout_height="match_parent"
26
- android:orientation="horizontal"
27
- android:layout_weight="5">
28
6
 
29
7
 
30
- </LinearLayout>
31
-
32
- <include
33
- layout="@layout/menu"
34
- android:layout_width="match_parent"
35
- android:layout_height="match_parent"
36
- android:layout_weight="5">
37
- </include>
38
- </LinearLayout>
39
-
40
- <LinearLayout
41
- android:layout_width="match_parent"
42
- android:layout_height="match_parent"
43
- android:layout_weight="2"
44
- android:background="@color/MainColor">
45
- <fragment
46
- android:id="@+id/Nav_Host"
47
- android:name="androidx.navigation.fragment.NavHostFragment"
48
- android:layout_width="match_parent"
49
- android:layout_height="match_parent"
50
- app:defaultNavHost="true"
51
- app:navGraph="@navigation/nav" />
52
- </LinearLayout>
53
- </LinearLayout>
54
- ```
55
-
56
- ![ss](https://ddjkaamml8q8x.cloudfront.net/questions/2022-01-24/474d2f71-35f1-4f69-b486-e2dcc2005ddb.png)
57
-
58
-