The Google doc Providing Up Navigation explains, how to display an Up button in an application with several Activities (by specifying "parent" Activities in AndroidManifest.xml):
However I am working on a Bluetooth application (starting with minSdkVersion=18
) which has a single MainActivity and 3 Fragments:
- MainFragment.java
- SettingsFragment.java
- ScanningFragment.java
So I have changed the base class to ActionBarActivity
:
public class MainActivity extends ActionBarActivity
implements BleWrapperUiCallbacks {
And I call the setDisplayHomeAsUpEnabled(true)
method:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
setContentView(R.layout.activity_root);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
This displays the Up button in my app, however I still have 3 questions:
- How to hide the Up button (when I am showing the MainFragment)?
- How to "wire" the Up button - currently touching it does nothing?
- What to use instead of the following line in my AndroidManifest.xml?
android:theme="@android:style/Theme.Holo.NoActionBar"