質問編集履歴

1

ソースコードを張りました

2023/05/13 08:44

投稿

tera877
tera877

スコア9

test CHANGED
File without changes
test CHANGED
@@ -33,8 +33,59 @@
33
33
 
34
34
  ### 該当のソースコード
35
35
 
36
- ```ここに言語名を入力
36
+ ```kotlin
37
- ソースコード
37
+ /*
38
+ * Copyright (C) 2020 The Android Open Source Project
39
+ *
40
+ * Licensed under the Apache License, Version 2.0 (the "License");
41
+ * you may not use this file except in compliance with the License.
42
+ * You may obtain a copy of the License at
43
+ *
44
+ * http://www.apache.org/licenses/LICENSE-2.0
45
+ *
46
+ * Unless required by applicable law or agreed to in writing, software
47
+ * distributed under the License is distributed on an "AS IS" BASIS,
48
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
49
+ * See the License for the specific language governing permissions and
50
+ * limitations under the License.
51
+ */
52
+ package com.example.wordsapp
53
+
54
+ import android.os.Bundle
55
+ import android.view.Menu
56
+ import android.view.MenuItem
57
+ import androidx.appcompat.app.AppCompatActivity
58
+ import androidx.core.content.ContextCompat
59
+ import androidx.navigation.NavController
60
+ import androidx.navigation.fragment.NavHostFragment
61
+ import androidx.navigation.ui.setupActionBarWithNavController
62
+ import androidx.recyclerview.widget.GridLayoutManager
63
+ import androidx.recyclerview.widget.LinearLayoutManager
64
+ import androidx.recyclerview.widget.RecyclerView
65
+ import com.example.wordsapp.databinding.ActivityMainBinding
66
+
67
+ /**
68
+ * Main Activity and entry point for the app. Displays a RecyclerView of letters.
69
+ */
70
+ class MainActivity : AppCompatActivity() {
71
+
72
+ private lateinit var navController: NavController
73
+
74
+ override fun onCreate(savedInstanceState: Bundle?) {
75
+ super.onCreate(savedInstanceState)
76
+
77
+ val navHostFragment = supportFragmentManager
78
+ .findFragmentById(R.id.nav_host_fragment) as NavHostFragment
79
+ navController = navHostFragment.navController
80
+
81
+ setupActionBarWithNavController(navController)
82
+ }
83
+
84
+ override fun onSupportNavigateUp(): Boolean {
85
+ return navController.navigateUp() || super.onSupportNavigateUp()
86
+ }
87
+ }
88
+
38
89
  ```
39
90
 
40
91
  ### 試したこと