Example usage for android.app ActionBar setDisplayHomeAsUpEnabled

List of usage examples for android.app ActionBar setDisplayHomeAsUpEnabled

Introduction

In this page you can find the example usage for android.app ActionBar setDisplayHomeAsUpEnabled.

Prototype

public abstract void setDisplayHomeAsUpEnabled(boolean showHomeAsUp);

Source Link

Document

Set whether home should be displayed as an "up" affordance.

Usage

From source file:com.matthewmitchell.peercoin_android_wallet.ui.AddressBookActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.address_book_content);

    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    final FragmentManager fragmentManager = getFragmentManager();

    walletAddressesFragment = (WalletAddressesFragment) fragmentManager.findFragmentByTag(TAG_LEFT);
    sendingAddressesFragment = (SendingAddressesFragment) fragmentManager.findFragmentByTag(TAG_RIGHT);

    final FragmentTransaction removal = fragmentManager.beginTransaction();

    if (walletAddressesFragment == null)
        walletAddressesFragment = new WalletAddressesFragment();
    else/*from   w  w w.j av a 2  s  .c  o m*/
        removal.remove(walletAddressesFragment);

    if (sendingAddressesFragment == null)
        sendingAddressesFragment = new SendingAddressesFragment();
    else
        removal.remove(sendingAddressesFragment);

    if (!removal.isEmpty()) {
        removal.commit();
        fragmentManager.executePendingTransactions();
    }

    final ViewPager pager = (ViewPager) findViewById(R.id.address_book_pager);
    if (pager != null) {
        pager.setAdapter(
                new TwoFragmentAdapter(fragmentManager, walletAddressesFragment, sendingAddressesFragment));

        final ViewPagerTabs pagerTabs = (ViewPagerTabs) findViewById(R.id.address_book_pager_tabs);
        pagerTabs.addTabLabels(R.string.address_book_list_receiving_title,
                R.string.address_book_list_sending_title);

        pager.setOnPageChangeListener(pagerTabs);
        final int position = 1;
        pager.setCurrentItem(position);
        pager.setPageMargin(2);
        pager.setPageMarginDrawable(R.color.bg_less_bright);

        pagerTabs.onPageSelected(position);
        pagerTabs.onPageScrolled(position, 0, 0);
    } else {
        fragmentManager.beginTransaction()
                .add(R.id.wallet_addresses_fragment, walletAddressesFragment, TAG_LEFT)
                .add(R.id.sending_addresses_fragment, sendingAddressesFragment, TAG_RIGHT).commit();
    }

    runAfterLoad(new Runnable() {

        @Override
        public void run() {
            updateFragments();
        }

    });

}

From source file:de.tudarmstadt.dvs.myhealthassistant.myhealthhub.activities.SensorSettingsActivity.java

@Override
public void onCreate(Bundle bundle) {
    super.onCreate(bundle);
    Log.e(TAG, "onCreate");

    setContentView(R.layout.sensor_connection_settings_fragment);

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    Bundle extras = getIntent().getExtras();
    sensorType = extras.getString("type");

    pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

    // Keeps reference to avoid future findViewById()
    viewHolder = new ViewHolder();
    viewHolder.tv_sensor_type = (TextView) findViewById(R.id.tv_sensor_type);
    viewHolder.tv_sensor_type.setText(sensorType);
    // -----//  w w  w .  java 2 s  .  c  o  m
    viewHolder.ll_bt_type = (LinearLayout) findViewById(R.id.ll_bluetooth_type);
    viewHolder.ll_bt_type.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            openSelectSensorType();
        }
    });

    deviceType = pref.getString(sensorType + SensorConfigFragment.deviceType, "");
    viewHolder.tv_bt_type_sum = (TextView) findViewById(R.id.tv_bluetooth_type_summary);
    viewHolder.tv_bt_type_sum.setText(deviceType);
    // -----
    viewHolder.ll_bt_sel = (LinearLayout) findViewById(R.id.ll_bluetooth_sel);
    viewHolder.ll_bt_sel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            openSelectDeviceDialog();
        }
    });

    viewHolder.tv_bt_sel_sum = (TextView) findViewById(R.id.tv_bluetooth_sel_summary);
    deviceMacAdd = pref.getString(sensorType + SensorConfigFragment.deviceMac, "");
    if (!deviceMacAdd.isEmpty()) {
        String name = getDeviceName(deviceMacAdd);
        viewHolder.tv_bt_sel_sum.setText(name + " (" + deviceMacAdd + ")");
    }
}

From source file:org.ounl.noisenotifier.SubjectsActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.fragment_section_subjects);

    db = new DatabaseHandler(getApplicationContext());

    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);

    intent = new Intent(this, PieChartActivity.class);
    lview = (ListView) findViewById(R.id.listviewSubjects);
    lview.setOnItemClickListener(new OnItemClickListener() {

        @Override//  w w w. j  a v  a2  s  .c o m
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            intent.putExtra("TAG", (String) view.getTag());

            Toast.makeText(SubjectsActivity.this, " Position clicked " + position, Toast.LENGTH_LONG).show();
            startActivity(intent);
        }
    });

}

From source file:com.battlelancer.seriesguide.ui.FullscreenImageActivity.java

private void setupActionBar() {
    final ActionBar actionBar = getActionBar();
    actionBar.setBackgroundDrawable(getResources().getDrawable(R.drawable.background_actionbar_gradient));
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setIcon(R.drawable.ic_actionbar);
    actionBar.setDisplayShowTitleEnabled(false);
}

From source file:com.mastercard.masterpasswallet.fragments.NavigationDrawerFragment.java

/**
 * Users of this fragment must call this method to set up the navigation drawer interactions.
 *
 * @param fragmentId   The android:id of this fragment in its activity's layout.
 * @param drawerLayout The DrawerLayout containing this fragment's UI.
 *///  ww  w  .ja v a  2  s  . com
public void setUp(int fragmentId, DrawerLayout drawerLayout) {
    mFragmentContainerView = getActivity().findViewById(fragmentId);
    mDrawerLayout = drawerLayout;

    // set a custom shadow that overlays the main content when the drawer opens
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // set up the drawer's list view with items and click listener

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    // ActionBarDrawerToggle ties together the the proper interactions
    // between the navigation drawer and the action bar app icon.
    mDrawerToggle = new ActionBarDrawerToggle(getActivity(), /* host Activity */
            mDrawerLayout, /* DrawerLayout object */
            R.drawable.ic_drawer, /* nav drawer image to replace 'Up' caret */
            R.string.navigation_drawer_open, /* "open drawer" description for accessibility */
            R.string.navigation_drawer_close /* "close drawer" description for accessibility */
    ) {
        @Override
        public void onDrawerClosed(View drawerView) {
            super.onDrawerClosed(drawerView);
            if (!isAdded()) {
                return;
            }

            getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu()
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            if (!isAdded()) {
                return;
            }

            getActivity().invalidateOptionsMenu(); // calls onPrepareOptionsMenu()
        }
    };

    // Defer code dependent on restoration of previous instance state.
    mDrawerLayout.post(new Runnable() {
        @Override
        public void run() {
            mDrawerToggle.syncState();
        }
    });

    mDrawerLayout.setDrawerListener(mDrawerToggle);
}

From source file:com.plnyyanks.frcnotebook.activities.ViewMatch.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(PreferenceHandler.getTheme());
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_view_match);

    activity = this;
    ActionBar bar = getActionBar();
    bar.setTitle(parentEvent.getEventName() + " - " + parentEvent.getEventYear());
    bar.setSubtitle(eventKey);/*from  ww  w.  j a  v  a  2s  . co  m*/
    bar.setDisplayHomeAsUpEnabled(true);

    if (matchKey == null)
        return;

    if (PreferenceHandler.getTheme() == R.style.theme_dark) {
        ImageView nextMatch = (ImageView) findViewById(R.id.next_match);
        nextMatch.setBackgroundResource(R.drawable.ic_action_next_item_dark);
        ImageView prevMatch = (ImageView) findViewById(R.id.prev_match);
        prevMatch.setBackgroundResource(R.drawable.ic_action_previous_item_dark);
    }

    new GetNotesForMatch(this).execute(previousKey, matchKey, nextKey, eventKey);

    if (PreferenceHandler.getFMEnabled()) {
        TextView fieldMonitor = (TextView) findViewById(R.id.field_monitor_link);
        fieldMonitor.setVisibility(View.VISIBLE);
        fieldMonitor.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(activity, FieldMonitorActivity.class);
                startActivity(intent);
            }
        });
    }
}

From source file:de.chaosdorf.meteroid.PickUsername.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    binding = DataBindingUtil.setContentView(this, R.layout.activity_pick_username);

    binding.buttonBack.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            Utility.startActivity(activity, SetHostname.class);
        }//from  ww  w  .  j  a  v  a 2 s. c  om
    });

    binding.buttonReload.setOnClickListener(new View.OnClickListener() {
        public void onClick(View view) {
            reload();
        }
    });

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        ActionBar actionBar = getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        binding.buttonReload.setVisibility(View.GONE);
        binding.buttonBack.setVisibility(View.GONE);
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        binding.swiperefresh.setEnabled(true);
        binding.swiperefresh.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
            @Override
            public void onRefresh() {
                reload();
            }
        });
        binding.fab.hide(false);
        binding.fab.attachToListView(binding.gridView);
        binding.fab.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Utility.startActivity(activity, UserSettings.class);
            }
        });
        binding.fab.setVisibility(View.VISIBLE);
        binding.fab.show();
    }

    reload();
}

From source file:com.evervolv.toolbox2.Toolbox.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mViewPager = new ViewPager(this);
    mViewPager.setId(R.id.pager);/*from w w  w .j  a  v  a  2 s . co m*/
    setContentView(mViewPager);

    final ActionBar bar = getActionBar();
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    bar.setDisplayOptions(0, ActionBar.DISPLAY_SHOW_TITLE);
    bar.setDisplayHomeAsUpEnabled(true);

    mTabsAdapter = new TabsAdapter(this, mViewPager);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.interface_title), Interface.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.performance_title), Performance.class, null);
    mTabsAdapter.addTab(bar.newTab().setText(R.string.updates_title), Updates.class, null);

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }
}

From source file:com.shinobicontrols.transitions.StoryDetailActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_story_detail);

    if (savedInstanceState == null) {
        // Load the data from the intent on first pass
        Intent intent = getIntent();/*from   w ww  .j av a2s.  com*/
        String story_id = intent.getStringExtra(ARG_STORY_ID);
        mItem = StoryContent.STORY_MAP.get(story_id);
    }

    // Get hold of some relevant content
    final ViewGroup container = (ViewGroup) findViewById(R.id.container);

    // What are the layouts we should be able to transition between
    List<Integer> sceneLayouts = Arrays.asList(R.layout.content_scene_00, R.layout.content_scene_01,
            R.layout.content_scene_02);
    // Create the scenes
    sceneList = new ArrayList<Scene>();
    for (int layout : sceneLayouts) {
        // Create the scene
        Scene scene = Scene.getSceneForLayout(container, layout, this);
        // Just before the transition starts, ensure that the content has been loaded
        scene.setEnterAction(new Runnable() {
            @Override
            public void run() {
                addContentToViewGroup(container);
            }
        });
        // Save the scene into
        sceneList.add(scene);
    }

    // Build the transition manager
    TransitionInflater transitionInflater = TransitionInflater.from(this);
    mTransitionManager = transitionInflater.inflateTransitionManager(R.transition.story_transition_manager,
            container);

    // Show the Up button in the action bar.
    final ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);

        // Specify we want some tabs
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

        // Create a listener to cope with tab changes
        ActionBar.TabListener tabListener = new ActionBar.TabListener() {
            @Override
            public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) {
                // If there's a scene for this tab index, then transition to it
                if (tab.getPosition() <= sceneList.size()) {
                    performTransitionToScene(sceneList.get(tab.getPosition()));
                }
            }

            @Override
            public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) {
                // Can ignore this event
            }

            @Override
            public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) {
                // Can ignore this event
            }

            private void performTransitionToScene(Scene scene) {
                mTransitionManager.transitionTo(scene);
            }
        };

        // Add some tabs
        for (int i = 0; i < sceneList.size(); i++) {
            actionBar.addTab(actionBar.newTab().setText("Scene " + i).setTabListener(tabListener));
        }
    }

    // Load the first scene
    sceneList.get(0).enter();
}

From source file:com.dabay6.android.apps.carlog.ui.SettingsActivity.java

/**
 * {@inheritDoc}/*from   w w w  .ja v a  2 s.  c  o m*/
 */
@TargetApi(VERSION_CODES.ICE_CREAM_SANDWICH)
@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    if (AndroidUtils.isAtLeastHoneycomb()) {
        @SuppressLint("AppCompatMethod")
        final android.app.ActionBar actionBar = getActionBar();

        if (actionBar != null) {
            actionBar.setDisplayHomeAsUpEnabled(true);
            actionBar.setSubtitle(getString(string.settings));

            if (AndroidUtils.isAtLeastICS()) {
                actionBar.setHomeButtonEnabled(true);
            }
        }
    }

    if (AndroidUtils.isVersionBefore(VERSION_CODES.HONEYCOMB)) {
        addPreferencesFromResource(xml.settings);
    }
}