Reputation: 19
I am a noob in android development and I follow the tutoral of the android website. 1. In the part of "Starting Another Activity", I just copied the code and tried to run it, but I found after the activity is changed (changed to new page), the title of action bar will change to the name of the class of that activity. 2. When it talks about the respond of the action button, the code is written as:
public boolean onOptionsItemSelected(MenuItem item) {
// Handle presses on the action bar items
switch (item.getItemId()) {
case R.id.action_search:
openSearch();
return true;
case R.id.action_settings:
openSettings();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
However, in the default code: `public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if (id == R.id.action_settings) {
return true;
}
return super.onOptionsItemSelected(item);
}`
It only return true which contains no method to respond(no openSettings()), but a "setting" word still pop out when I press it. 3. How do I remove the action bar and make it full screen?
Upvotes: 0
Views: 131
Reputation: 2258
Check the menu file under res/menu/your_menu_file.xml. I think it contains something like
<item
android:id="@+id/action_settings"
android:orderInCategory="100"
android:showAsAction="never"
android:title="@string/action_settings"/>
The displayed icon is NOT setting icon, but overflow icon. If the overflow icon is clicked, it lists all menu items. In your case only one (i.e Setting)
To hide the action bar, include these in your onCreate() method
//getWindow().requestWindowFeature(Window.FEATURE_NO_TITLE);
getActionBar().hide();
You can also do it via xml. Look at this SO question.
Upvotes: 0
Reputation: 6286
Don't fully understand your question (you really didn't ask one specifically) but I think this is what you're asking
How to change the title of a new activity?
How does settings open up?
Android does this automatically, if the onCreateOptionsMenu(Menu menu)
is called.
How do i make a full screen activity?
In the future, be sure to look through Google and StackOverflow for you answers, most likely someone has already asked a similar question
Upvotes: 1