Hi there! Please sign in
help
tags
users
badges
ALL
UNANSWERED
Ask Your Question
Revision history [
back
]
1
initial version
answered
2022-01-03 02:00:00 +0000
pufferfish
41
●
3
●
2
Create a new menu xml file in the res/menu folder.
Add an item to the menu with the attribute android:id="@+id/text
view
menu_item" and android:title="TextView".
In the Main Activity's onCreateOptionsMenu() method, inflate the menu xml file and return true.
In the Main Activity's onOptionsItemSelected() method, check if the selected menu item is the text
view
menu_item.
If it is, create a new TextView element using the findViewById() method with the id R.id.text_view, and set its text to "Hello World".
Finally, add the TextView element to the Main Activity's layout using the addView() method of the parent container.
Copyright QStack.ai, 2010-2023. Content on this site is licensed under the Creative Commons Attribution Share Alike 3.0 license.
Please note: QStack requires javascript to work properly, please enable javascript in your browser,
here is how