Action bar icon as up

This commit is contained in:
serso 2015-02-01 20:25:13 +01:00
parent 9154f9b508
commit 2396de20a4
2 changed files with 16 additions and 2 deletions

View File

@ -94,13 +94,16 @@ public class ActivityUi extends BaseUi {
onCreate((Activity) activity);
final ActionBar actionBar = activity.getSupportActionBar();
actionBar.setDisplayUseLogoEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(false);
final boolean homeAsUp = !(activity instanceof CalculatorActivity);
actionBar.setDisplayHomeAsUpEnabled(homeAsUp);
actionBar.setHomeButtonEnabled(false);
actionBar.setDisplayShowHomeEnabled(true);
toggleTitle(activity, true);
if (!homeAsUp) {
actionBar.setIcon(R.drawable.ab_icon);
}
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
}

View File

@ -3,6 +3,7 @@ package org.solovyev.android.calculator;
import android.os.Bundle;
import android.support.annotation.LayoutRes;
import android.support.v7.app.ActionBarActivity;
import android.view.MenuItem;
import javax.annotation.Nonnull;
@ -70,4 +71,14 @@ public class BaseActivity extends ActionBarActivity {
super.onDestroy();
ui.onDestroy(this);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
}