Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
E
ElBuenoPeso
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Matis SPINELLI
ElBuenoPeso
Commits
ba02b6a8
Commit
ba02b6a8
authored
Feb 20, 2024
by
Timothé KOBAK
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bonus Button : Settings Exit added
parent
d8f27b64
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
56 additions
and
4 deletions
+56
-4
MainActivity.kt
app/src/main/java/com/example/elbuenopeso/MainActivity.kt
+28
-4
menu.xml
app/src/main/res/menu/menu.xml
+28
-0
No files found.
app/src/main/java/com/example/elbuenopeso/MainActivity.kt
View file @
ba02b6a8
package
com.example.elbuenopeso
package
com.example.elbuenopeso
import
AdAdapter
import
android.os.Bundle
import
android.os.Bundle
import
com.google.android.material.bottomnavigation.BottomNavigationView
import
android.view.Menu
import
android.view.MenuItem
import
android.widget.Toast
import
androidx.appcompat.app.AppCompatActivity
import
androidx.appcompat.app.AppCompatActivity
import
androidx.navigation.findNavController
import
androidx.navigation.findNavController
import
androidx.navigation.ui.AppBarConfiguration
import
androidx.navigation.ui.AppBarConfiguration
import
androidx.navigation.ui.setupActionBarWithNavController
import
androidx.navigation.ui.setupActionBarWithNavController
import
androidx.navigation.ui.setupWithNavController
import
androidx.navigation.ui.setupWithNavController
import
com.example.elbuenopeso.databinding.ActivityMainBinding
import
com.example.elbuenopeso.databinding.ActivityMainBinding
import
com.
example.elbuenopeso.models.AdModel
import
com.
google.android.material.bottomnavigation.BottomNavigationView
class
MainActivity
:
AppCompatActivity
()
{
class
MainActivity
:
AppCompatActivity
()
{
...
@@ -24,6 +25,7 @@ class MainActivity : AppCompatActivity() {
...
@@ -24,6 +25,7 @@ class MainActivity : AppCompatActivity() {
val
navView
:
BottomNavigationView
=
binding
.
navView
val
navView
:
BottomNavigationView
=
binding
.
navView
val
navController
=
findNavController
(
R
.
id
.
nav_host_fragment_activity_main
)
val
navController
=
findNavController
(
R
.
id
.
nav_host_fragment_activity_main
)
// Passing each menu ID as a set of Ids because each
// Passing each menu ID as a set of Ids because each
// menu should be considered as top level destinations.
// menu should be considered as top level destinations.
val
appBarConfiguration
=
AppBarConfiguration
(
val
appBarConfiguration
=
AppBarConfiguration
(
...
@@ -34,6 +36,28 @@ class MainActivity : AppCompatActivity() {
...
@@ -34,6 +36,28 @@ class MainActivity : AppCompatActivity() {
setupActionBarWithNavController
(
navController
,
appBarConfiguration
)
setupActionBarWithNavController
(
navController
,
appBarConfiguration
)
navView
.
setupWithNavController
(
navController
)
navView
.
setupWithNavController
(
navController
)
}
override
fun
onCreateOptionsMenu
(
menu
:
Menu
?):
Boolean
{
menuInflater
.
inflate
(
R
.
menu
.
menu
,
menu
)
return
true
}
override
fun
onOptionsItemSelected
(
item
:
MenuItem
):
Boolean
{
when
(
item
.
itemId
)
{
R
.
id
.
about
->
{
Toast
.
makeText
(
this
,
"About Selected"
,
Toast
.
LENGTH_SHORT
).
show
()
return
true
}
R
.
id
.
settings
->
{
Toast
.
makeText
(
this
,
"Settings Selected"
,
Toast
.
LENGTH_SHORT
).
show
()
return
true
}
R
.
id
.
exit
->
{
Toast
.
makeText
(
this
,
"Exit Selected"
,
Toast
.
LENGTH_SHORT
).
show
()
return
true
}
else
->
return
super
.
onOptionsItemSelected
(
item
)
}
}
}
}
}
\ No newline at end of file
app/src/main/res/menu/menu.xml
0 → 100644
View file @
ba02b6a8
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android=
"http://schemas.android.com/apk/res/android"
xmlns:app=
"http://schemas.android.com/apk/res-auto"
>
<item
android:id=
"@+id/overflowMenu"
android:icon=
"@drawable/ic_home_black_24dp"
android:title=
""
app:showAsAction=
"always"
>
<menu>
<item
android:id=
"@+id/settings"
android:icon=
"@drawable/ic_home_black_24dp"
android:title=
"SETTINGS"
app:showAsAction=
"never"
/>
<item
android:id=
"@+id/about"
android:icon=
"@drawable/ic_home_black_24dp"
android:title=
"ABOUT"
app:showAsAction=
"never"
/>
<item
android:id=
"@+id/exit"
android:icon=
"@drawable/ic_home_black_24dp"
android:title=
"EXIT"
app:showAsAction=
"never"
/>
</menu>
</item>
</menu>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment