File tree 5 files changed +31
-3
lines changed
java/com/google/samples/quickstart/admobexample
5 files changed +31
-3
lines changed Original file line number Diff line number Diff line change 17
17
18
18
import android .os .Bundle ;
19
19
import androidx .appcompat .app .AppCompatActivity ;
20
+ import androidx .navigation .Navigation ;
20
21
21
22
import com .google .samples .quickstart .admobexample .R ;
22
23
@@ -26,6 +27,7 @@ public class MainActivity extends AppCompatActivity {
26
27
protected void onCreate (Bundle savedInstanceState ) {
27
28
super .onCreate (savedInstanceState );
28
29
setContentView (R .layout .activity_main );
30
+ Navigation .findNavController (this , R .id .nav_host_fragment ).setGraph (R .navigation .nav_graph_java );
29
31
}
30
32
31
33
}
Original file line number Diff line number Diff line change @@ -2,12 +2,15 @@ package com.google.samples.quickstart.admobexample.kotlin
2
2
3
3
import android.os.Bundle
4
4
import androidx.appcompat.app.AppCompatActivity
5
+ import androidx.navigation.findNavController
5
6
import com.google.samples.quickstart.admobexample.R
6
7
7
8
class MainActivity : AppCompatActivity () {
8
9
9
10
override fun onCreate (savedInstanceState : Bundle ? ) {
10
11
super .onCreate(savedInstanceState)
11
12
setContentView(R .layout.activity_main)
13
+
14
+ findNavController(R .id.nav_host_fragment).setGraph(R .navigation.nav_graph_kotlin)
12
15
}
13
16
}
Original file line number Diff line number Diff line change 15
15
app : layout_constraintBottom_toBottomOf =" parent"
16
16
app : layout_constraintLeft_toLeftOf =" parent"
17
17
app : layout_constraintRight_toRightOf =" parent"
18
- app : layout_constraintTop_toTopOf =" parent"
19
- app : navGraph =" @navigation/nav_graph" />
18
+ app : layout_constraintTop_toTopOf =" parent" />
20
19
21
20
</androidx .constraintlayout.widget.ConstraintLayout>
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" utf-8" ?>
2
+ <navigation xmlns : android =" http://schemas.android.com/apk/res/android"
3
+ xmlns : app =" http://schemas.android.com/apk/res-auto"
4
+ xmlns : tools =" http://schemas.android.com/tools"
5
+ android : id =" @+id/nav_graph_java"
6
+ app : startDestination =" @id/FirstFragment" >
7
+
8
+ <fragment
9
+ android : id =" @+id/FirstFragment"
10
+ android : name =" com.google.samples.quickstart.admobexample.java.FirstFragment"
11
+ android : label =" @string/first_fragment_title"
12
+ tools : layout =" @layout/fragment_first" >
13
+
14
+ <action
15
+ android : id =" @+id/action_FirstFragment_to_SecondFragment"
16
+ app : destination =" @id/SecondFragment" />
17
+ </fragment >
18
+ <fragment
19
+ android : id =" @+id/SecondFragment"
20
+ android : name =" com.google.samples.quickstart.admobexample.java.SecondFragment"
21
+ android : label =" @string/second_fragment_title"
22
+ tools : layout =" @layout/fragment_second" >
23
+ </fragment >
24
+ </navigation >
Original file line number Diff line number Diff line change 2
2
<navigation xmlns : android =" http://schemas.android.com/apk/res/android"
3
3
xmlns : app =" http://schemas.android.com/apk/res-auto"
4
4
xmlns : tools =" http://schemas.android.com/tools"
5
- android : id =" @+id/nav_graph "
5
+ android : id =" @+id/nav_graph_kotlin "
6
6
app : startDestination =" @id/FirstFragment" >
7
7
8
8
<fragment
You can’t perform that action at this time.
0 commit comments