1
1
package com .lcl .lclmeasurementtool ;
2
2
3
- import android .os .Bundle ;
4
-
5
- import com .google .android .material .snackbar .Snackbar ;
6
-
7
3
import androidx .appcompat .app .AppCompatActivity ;
8
4
9
- import android .view .View ;
10
-
11
- import androidx .navigation .NavController ;
12
- import androidx .navigation .Navigation ;
13
- import androidx .navigation .ui .AppBarConfiguration ;
14
- import androidx .navigation .ui .NavigationUI ;
15
-
16
- import com .lcl .lclmeasurementtool .databinding .ActivityMainBinding ;
17
-
18
- import android .view .Menu ;
19
- import android .view .MenuItem ;
5
+ import android .os .Bundle ;
20
6
21
7
public class MainActivity extends AppCompatActivity {
22
8
23
- private AppBarConfiguration appBarConfiguration ;
24
- private ActivityMainBinding binding ;
25
-
26
9
@ Override
27
10
protected void onCreate (Bundle savedInstanceState ) {
28
11
super .onCreate (savedInstanceState );
29
-
30
- binding = ActivityMainBinding .inflate (getLayoutInflater ());
31
- setContentView (binding .getRoot ());
32
-
33
- setSupportActionBar (binding .toolbar );
34
-
35
- NavController navController = Navigation .findNavController (this , R .id .nav_host_fragment_content_main );
36
- appBarConfiguration = new AppBarConfiguration .Builder (navController .getGraph ()).build ();
37
- NavigationUI .setupActionBarWithNavController (this , navController , appBarConfiguration );
38
-
39
- binding .fab .setOnClickListener (new View .OnClickListener () {
40
- @ Override
41
- public void onClick (View view ) {
42
- Snackbar .make (view , "Replace with your own action" , Snackbar .LENGTH_LONG )
43
- .setAction ("Action" , null ).show ();
44
- }
45
- });
46
- }
47
-
48
- @ Override
49
- public boolean onCreateOptionsMenu (Menu menu ) {
50
- // Inflate the menu; this adds items to the action bar if it is present.
51
- getMenuInflater ().inflate (R .menu .menu_main , menu );
52
- return true ;
53
- }
54
-
55
- @ Override
56
- public boolean onOptionsItemSelected (MenuItem item ) {
57
- // Handle action bar item clicks here. The action bar will
58
- // automatically handle clicks on the Home/Up button, so long
59
- // as you specify a parent activity in AndroidManifest.xml.
60
- int id = item .getItemId ();
61
-
62
- //noinspection SimplifiableIfStatement
63
- if (id == R .id .action_settings ) {
64
- return true ;
65
- }
66
-
67
- return super .onOptionsItemSelected (item );
68
- }
69
-
70
- @ Override
71
- public boolean onSupportNavigateUp () {
72
- NavController navController = Navigation .findNavController (this , R .id .nav_host_fragment_content_main );
73
- return NavigationUI .navigateUp (navController , appBarConfiguration )
74
- || super .onSupportNavigateUp ();
12
+ setContentView (R .layout .activity_main );
75
13
}
76
14
}
0 commit comments