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.squareup.leakcanary.internal.DisplayLeakActivity.java

private void setDisplayHomeAsUpEnabled(boolean enabled) {
    ActionBar actionBar = getActionBar();
    if (actionBar == null) {
        // https://github.com/square/leakcanary/issues/967
        return;// ww  w  . j  a v  a2 s.c  o m
    }
    actionBar.setDisplayHomeAsUpEnabled(enabled);
}

From source file:com.af.synapse.MainActivity.java

@SuppressWarnings("ConstantConditions")
private void continueCreate() {
    View v = LayoutInflater.from(this).inflate(R.layout.activity_main, null);

    mViewPager = (ViewPager) v.findViewById(R.id.mainPager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPagerPageChangeListener());
    mDrawerList = (ListView) v.findViewById(R.id.left_drawer);

    String[] section_titles = new String[Utils.configSections.size()];
    for (int i = 0; i < Utils.configSections.size(); i++)
        section_titles[i] = Utils.localise(((JSONObject) Utils.configSections.get(i)).get("name"));

    mDrawerList.setAdapter(new ArrayAdapter<String>(this, R.layout.drawer_item, section_titles));
    mDrawerList.setOnItemClickListener(new DrawerItemClickListener());
    mDrawerList.setItemChecked(0, true);

    mDrawerLayout = (DrawerLayout) v.findViewById(R.id.drawer_layout);
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open,
            R.string.drawer_close);/*from www  .  j  a v a 2s  . c om*/
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    ActionBar actionBar = getActionBar();

    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setHomeButtonEnabled(true);

    mDrawerToggle.syncState();

    ActionValueUpdater.refreshButtons(true);

    for (TabSectionFragment f : fragments)
        f.onElementsMainStart();

    setContentView(v);
    actionBar.show();
    Utils.appStarted = true;

    setPaddingDimensions();
    L.i("Interface creation finished in " + (System.nanoTime() - startTime) + "ns");

    if (Utils.appStarted)
        this.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);

    if (!BootService.getBootFlag() && !BootService.getBootFlagPending()) {
        new AlertDialog.Builder(this).setTitle(R.string.popup_failed_boot_title)
                .setMessage(R.string.popup_failed_boot_message).setCancelable(true)
                .setPositiveButton(R.string.popup_failed_boot_ack, new DialogInterface.OnClickListener() {
                    public void onClick(DialogInterface dialog, int which) {
                    }
                }).show();
    }
}

From source file:cn.edu.nju.dapenti.activity.EditFeedActivity.java

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

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

    setContentView(R.layout.activity_feed_edit);
    setResult(RESULT_CANCELED);/*www . j  a v  a2s.  c  o  m*/

    Intent intent = getIntent();

    mNameEditText = (EditText) findViewById(R.id.feed_title);
    mUrlEditText = (EditText) findViewById(R.id.feed_url);
    mRetrieveFulltextCb = (CheckBox) findViewById(R.id.retrieve_fulltext);
    mFiltersListView = (ListView) findViewById(android.R.id.list);
    View filtersLayout = findViewById(R.id.filters_layout);
    View buttonLayout = findViewById(R.id.button_layout);

    if (intent.getAction().equals(Intent.ACTION_INSERT) || intent.getAction().equals(Intent.ACTION_SEND)) {
        setTitle(R.string.new_feed_title);

        filtersLayout.setVisibility(View.GONE);

        if (intent.hasExtra(Intent.EXTRA_TEXT)) {
            mUrlEditText.setText(intent.getStringExtra(Intent.EXTRA_TEXT));
        }

        restoreInstanceState(savedInstanceState);
    } else if (intent.getAction().equals(Intent.ACTION_EDIT)) {
        setTitle(R.string.edit_feed_title);

        buttonLayout.setVisibility(View.GONE);

        mFiltersCursorAdapter = new FiltersCursorAdapter(this, null);
        mFiltersListView.setAdapter(mFiltersCursorAdapter);
        mFiltersListView.setOnItemLongClickListener(new OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                startActionMode(mFilterActionModeCallback);
                mFiltersCursorAdapter.setSelectedFilter(position);
                mFiltersListView.invalidateViews();
                return true;
            }
        });

        getLoaderManager().initLoader(0, null, this);

        if (!restoreInstanceState(savedInstanceState)) {
            Cursor cursor = getContentResolver().query(intent.getData(), FEED_PROJECTION, null, null, null);

            if (cursor.moveToNext()) {
                mPreviousName = cursor.getString(0);
                mNameEditText.setText(mPreviousName);
                mUrlEditText.setText(cursor.getString(1));
                mRetrieveFulltextCb.setChecked(cursor.getInt(2) == 1);
                cursor.close();
            } else {
                cursor.close();
                Toast.makeText(EditFeedActivity.this, R.string.error, Toast.LENGTH_SHORT).show();
                finish();
            }
        }
    }
}

From source file:co.nerdart.ourss.activity.EditFeedActivity.java

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

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

    setContentView(R.layout.feed_edit);//from w  w  w .  ja  v  a2s.c  o  m
    setResult(RESULT_CANCELED);

    Intent intent = getIntent();

    mNameEditText = (EditText) findViewById(R.id.feed_title);
    mUrlEditText = (EditText) findViewById(R.id.feed_url);
    mRetrieveFulltextCb = (CheckBox) findViewById(R.id.retrieve_fulltext);
    mFiltersListView = (ListView) findViewById(android.R.id.list);
    View filtersLayout = findViewById(R.id.filters_layout);
    View buttonLayout = findViewById(R.id.button_layout);

    if (intent.getAction().equals(Intent.ACTION_INSERT) || intent.getAction().equals(Intent.ACTION_SEND)) {
        setTitle(R.string.new_feed_title);

        filtersLayout.setVisibility(View.GONE);

        if (intent.hasExtra(Intent.EXTRA_TEXT)) {
            mUrlEditText.setText(intent.getStringExtra(Intent.EXTRA_TEXT));
        }

        restoreInstanceState(savedInstanceState);
    } else if (intent.getAction().equals(Intent.ACTION_EDIT)) {
        setTitle(R.string.edit_feed_title);

        buttonLayout.setVisibility(View.GONE);

        mFiltersCursorAdapter = new FiltersCursorAdapter(this, null);
        mFiltersListView.setAdapter(mFiltersCursorAdapter);
        mFiltersListView.setOnItemLongClickListener(new OnItemLongClickListener() {
            @Override
            public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long id) {
                startActionMode(mFilterActionModeCallback);
                mFiltersCursorAdapter.setSelectedFilter(position);
                mFiltersListView.invalidateViews();
                return true;
            }
        });

        getLoaderManager().initLoader(0, null, this);

        if (!restoreInstanceState(savedInstanceState)) {
            Cursor cursor = getContentResolver().query(intent.getData(), FEED_PROJECTION, null, null, null);

            if (cursor.moveToNext()) {
                mPreviousName = cursor.getString(0);
                mNameEditText.setText(mPreviousName);
                mUrlEditText.setText(cursor.getString(1));
                mRetrieveFulltextCb.setChecked(cursor.getInt(2) == 1);
                cursor.close();
            } else {
                cursor.close();
                Crouton.makeText(EditFeedActivity.this, R.string.error, Style.INFO);
                finish();
            }
        }
    }
}

From source file:dk.bearware.gui.AudioCodecActivity.java

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

    audiocodec = Utils.getAudioCodec(this.getIntent());

    int tab_index = 0;
    switch (audiocodec.nCodec) {
    case Codec.OPUS_CODEC:
        opuscodec = audiocodec.opus;// ww w.ja va2  s. c o m
        tab_index = TAB_OPUS;
        break;
    case Codec.SPEEX_CODEC:
        speexcodec = audiocodec.speex;
        tab_index = TAB_SPEEX;
        break;
    case Codec.SPEEX_VBR_CODEC:
        speexvbrcodec = audiocodec.speex_vbr;
        tab_index = TAB_SPEEXVBR;
        break;
    case Codec.NO_CODEC:
        tab_index = TAB_NOAUDIO;
        break;
    }

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayHomeAsUpEnabled(true);

    // Create the adapter that will return a fragment for each of the three
    // primary sections of the activity.
    mSectionsPagerAdapter = new SectionsPagerAdapter(getFragmentManager());

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    // When swiping between different sections, select the corresponding
    // tab. We can also use ActionBar.Tab#select() to do this if we have
    // a reference to the Tab.
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mSectionsPagerAdapter.getCount(); i++) {
        // Create a tab with text corresponding to the page title defined by
        // the adapter. Also specify this Activity object, which implements
        // the TabListener interface, as the callback (listener) for when
        // this tab is selected.
        actionBar
                .addTab(actionBar.newTab().setText(mSectionsPagerAdapter.getPageTitle(i)).setTabListener(this));
    }

    mViewPager.setCurrentItem(tab_index);
}

From source file:com.jiusg.mainscreenshow.ui.MSS.java

/**
 * ActionBar//  www  .j  a  v  a  2  s  .  c om
 *
 * @param layoutId Id
 */
public void setActionBarLayout(int layoutId) {
    ActionBar actionBar = getActionBar();
    if (null != actionBar) {
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(false);
        actionBar.setDisplayUseLogoEnabled(false);

        LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
        View v = inflator.inflate(layoutId, null);
        ActionBar.LayoutParams layout = new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT);
        actionBar.setCustomView(v, layout);
    }
}

From source file:org.catrobat.catroid.ui.MainMenuActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    if (!Utils.checkForExternalStorageAvailableAndDisplayErrorIfNot(this)) {
        return;/* w  w w .  j  av  a2s. com*/
    }
    initializeFacebookSdk();

    PreferenceManager.setDefaultValues(this, R.xml.preferences, true);
    UtilUi.updateScreenWidthAndHeight(this);

    if (STANDALONE_MODE) {
        /*requestWindowFeature(Window.FEATURE_NO_TITLE);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
           WindowManager.LayoutParams.FLAG_FULLSCREEN);*/
        getActionBar().hide();
        setContentView(R.layout.activity_main_menu_splashscreen);
        unzipProgram();
    } else {
        setContentView(R.layout.activity_main_menu);

        final ActionBar actionBar = getActionBar();
        actionBar.setDisplayUseLogoEnabled(true);
        actionBar.setHomeButtonEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(false);
        actionBar.setTitle(R.string.app_name);

        findViewById(R.id.main_menu_button_continue).setEnabled(false);

        // Load external project from URL or local file system.
        Uri loadExternalProjectUri = getIntent().getData();
        getIntent().setData(null);

        if (loadExternalProjectUri != null) {
            loadProgramFromExternalSource(loadExternalProjectUri);
        }
    }
}

From source file:com.alcoapps.navigationdrawer.NavdrawerModule.java

@Kroll.method
public void attach() {
    // as a first step I'll play around with the actual activity and actionbar to make sure
    // I can properly get access to it

    // some feedback is always nice
    Log.d(TAG, "called the attach method");

    // declare stuff
    TiApplication appContext = TiApplication.getInstance();
    Activity activity = appContext.getCurrentActivity();
    ActionBar actionBar;

    if (!TiApplication.isUIThread()) {

        // Within which the entire activity is enclosed
        //DrawerLayout mDrawerLayout;

        // ListView represents Navigation Drawer
        //ListView mDrawerList;

        // ActionBarDrawerToggle indicates the presence of Navigation Drawer in the action bar
        //ActionBarDrawerToggle mDrawerToggle;

        // Play with the action bar
        String mTitle = "This is a test";
        String mSubtitle = "This is the subtitle";

        actionBar = activity.getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setSubtitle(mSubtitle);
        actionBar.setTitle(mTitle);//from  w  w  w  . j a v a 2  s.c o  m
    }
}

From source file:com.retroteam.studio.retrostudio.MeasureEditor.java

/**
 * Set up the {@link android.app.ActionBar}, if the API is available.
 *//*w  ww  .  j a v a 2s.c o  m*/
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void setupActionBar(String title) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        // Show the Up button in the action bar.
        ActionBar measure = getActionBar();
        //actionMenu = measure;
        measure.setDisplayHomeAsUpEnabled(true);
        measure.setTitle("Editing Measure " + title.split(",")[0] + ", " + title.split(",")[1]);

    }
}

From source file:io.indy.drone.activity.StrikeDetailActivity.java

private void configureActionBar() {
    // Show the Up button in the action bar.
    ActionBar actionBar = getActionBar();

    mSpinnerAdapter = ArrayAdapter.createFromResource(this, R.array.locations_array,
            android.R.layout.simple_spinner_dropdown_item);

    mOnNavigationListener = new ActionBar.OnNavigationListener() {
        public boolean onNavigationItemSelected(int itemPosition, long itemId) {
            onRegionSelected(itemPosition);
            return true;
        }/*from  w  w w  . jav a2  s. c  o m*/
    };

    actionBar.setTitle("");
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);

    try {
        actionBar.setSelectedNavigationItem(SQLDatabase.indexFromRegion(mRegion));
    } catch (Exception e) {
        e.printStackTrace();
    }
}