Issue
There are a few things I want to do, but I don't know if I did this right.
I simply created an Activity and declared its android:parentActivityName
in the AndroidManifest.xml
.
When I click on an item in my ListView from my first fragment in my ViewPager, it takes me to that activity. When I press the Back
button on my phone, it takes me back to the exact state that the Fragment and the ViewPager were in. However, when I press the Up
button in my ActionBar, I am taken back to the Fragment and ActionBar but it seems to reload everything. I have found answers for applying the Back functionality to the Up button, but for some reason I can't reference the Up button in anyway.
When I view my menu file corresponding to the top, all I see is:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
tools:context="com.unlock.gate.CommentsActivity">
<item android:id="@+id/action_settings"
android:title="@string/action_settings"
android:orderInCategory="100"
android:showAsAction="never"/>
</menu>
This is perplexing because I don't even see the three vertical dots representing the Settings but see the Up button. How do I alleviate this issue? Also, the label for this Activity is Comments
. When I press the Up button
, it seems to include the label in the highlighting. I would like these separated such that the Up button is by itself and the Label just sits there without being manipulated with the button.
Solution
public void onMenuItemPressed(MenuItem item){
switch(item.getId)
{
case android.R.id.home :
onBackPressed();
....
return;
...
}
}
You can override up button pressed like this.
Answered By - Emre Aktürk
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.