Reputation: 22988
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:
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:
android:theme="@android:style/Theme.Holo.NoActionBar"
Upvotes: 2
Views: 104
Reputation: 458
I can answer the second question for providing the up navigation by override this method :
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
// Respond to the action bar's Up/Home button
case android.R.id.home:
NavUtils.navigateUpFromSameTask(this);
return true;
}
return super.onOptionsItemSelected(item);
}
Upvotes: 2