I am using ActionBarSherlock (although I do not think it matters).
I have a main action and activity. I want the "About Activity" function to display the back arrow in its logo and perform the corresponding animation. I do not know how to do it properly.
I currently have onOptionsMenuItemSelected to trigger the main action when I press the Up / Home button, but it is hacked and does not work correctly. It plays incorrect animation and poorly handles multitasking.
How do I configure this correctly?
Here is part of my main activity that launches About:
Intent aboutIntent = new Intent(MainActivity.this, About.class); MainActivity.this.startActivity(aboutIntent);
Here is my About Activity:
package com.stevenschoen.test; import android.content.Intent; import android.os.Bundle; import com.actionbarsherlock.app.SherlockActivity; import com.actionbarsherlock.view.MenuItem; public class About extends SherlockActivity { public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.about); getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayShowTitleEnabled(false); } public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case android.R.id.home:
java android android-actionbar
Steven Schoen Jul 03 '12 at 4:30 2012-07-03 04:30
source share