Example usage for android.app ActionBar DISPLAY_HOME_AS_UP

List of usage examples for android.app ActionBar DISPLAY_HOME_AS_UP

Introduction

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

Prototype

int DISPLAY_HOME_AS_UP

To view the source code for android.app ActionBar DISPLAY_HOME_AS_UP.

Click Source Link

Document

Display the 'home' element such that it appears as an 'up' affordance.

Usage

From source file:com.xandy.calendar.selectcalendars.SelectVisibleCalendarsActivity.java

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    //        getActionBar()
    getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP);
    return true;/*w ww. j  a  va  2s  . c om*/
}

From source file:com.xandy.calendar.SearchActivity.java

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    // This needs to be created before setContentView
    mController = CalendarController.getInstance(this);
    mHandler = new Handler();

    mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config);
    mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda);

    setContentView(R.layout.search);/*from  ww  w  .j  a va  2s  . c om*/

    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);

    mContentResolver = getContentResolver();

    if (mIsMultipane) {
        getActionBar().setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP);
    } else {
        getActionBar().setDisplayOptions(0, ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME);
    }

    // Must be the first to register because this activity can modify the
    // list of event handlers in it's handle method. This affects who the
    // rest of the handlers the controller dispatches to are.
    mController.registerEventHandler(HANDLER_KEY, this);

    mDeleteEventHelper = new DeleteEventHelper(this, this, false /* don't exit when done */);

    long millis = 0;
    if (icicle != null) {
        // Returns 0 if key not found
        millis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME);
        if (DEBUG) {
            Log.v(TAG, "Restore value from icicle: " + millis);
        }
    }
    if (millis == 0) {
        // Didn't find a time in the bundle, look in intent or current time
        millis = Utils.timeFromIntentInMillis(getIntent());
    }

    Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query;
        if (icicle != null && icicle.containsKey(BUNDLE_KEY_RESTORE_SEARCH_QUERY)) {
            query = icicle.getString(BUNDLE_KEY_RESTORE_SEARCH_QUERY);
        } else {
            query = intent.getStringExtra(SearchManager.QUERY);
        }
        if ("TARDIS".equalsIgnoreCase(query)) {
            Utils.tardis();
        }
        initFragments(millis, query);
    }
}

From source file:com.android.calendar.SearchActivity.java

@Override
protected void onCreate(Bundle icicle) {
    super.onCreate(icicle);
    dynamicTheme.onCreate(this);
    // This needs to be created before setContentView
    mController = CalendarController.getInstance(this);
    mHandler = new Handler();

    mIsMultipane = Utils.getConfigBool(this, R.bool.multiple_pane_config);
    mShowEventDetailsWithAgenda = Utils.getConfigBool(this, R.bool.show_event_details_with_agenda);

    setContentView(R.layout.search);//from w  ww  .ja  v  a  2s .  c o  m

    setDefaultKeyMode(DEFAULT_KEYS_SEARCH_LOCAL);

    mContentResolver = getContentResolver();

    if (mIsMultipane) {
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP);
        }
    } else {
        if (getSupportActionBar() != null) {
            getSupportActionBar().setDisplayOptions(0,
                    ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME);
        }
    }

    // Must be the first to register because this activity can modify the
    // list of event handlers in it's handle method. This affects who the
    // rest of the handlers the controller dispatches to are.
    mController.registerEventHandler(HANDLER_KEY, this);

    mDeleteEventHelper = new DeleteEventHelper(this, this, false /* don't exit when done */);

    long millis = 0;
    if (icicle != null) {
        // Returns 0 if key not found
        millis = icicle.getLong(BUNDLE_KEY_RESTORE_TIME);
        if (DEBUG) {
            Log.v(TAG, "Restore value from icicle: " + millis);
        }
    }
    if (millis == 0) {
        // Didn't find a time in the bundle, look in intent or current time
        millis = Utils.timeFromIntentInMillis(getIntent());
    }

    Intent intent = getIntent();
    if (Intent.ACTION_SEARCH.equals(intent.getAction())) {
        String query;
        if (icicle != null && icicle.containsKey(BUNDLE_KEY_RESTORE_SEARCH_QUERY)) {
            query = icicle.getString(BUNDLE_KEY_RESTORE_SEARCH_QUERY);
        } else {
            query = intent.getStringExtra(SearchManager.QUERY);
        }
        if ("TARDIS".equalsIgnoreCase(query)) {
            Utils.tardis();
        }
        initFragments(millis, query);
    }
}

From source file:com.docd.purefm.ui.activities.SearchActivity.java

private void initActionBar() {
    //noinspection InflateParams
    final View actionBarCustom = this.getLayoutInflater().inflate(R.layout.activity_search_actionbar, null);
    if (actionBarCustom == null) {
        throw new RuntimeException("Inflated View is null");
    }/*from   w  w w  .  j a va2 s . co m*/

    final TextView path = (TextView) actionBarCustom.findViewById(android.R.id.text1);
    path.setText(mStartDirectory.getAbsolutePath());

    final ActionBar bar = this.getActionBar();
    if (bar == null) {
        throw new RuntimeException("ActionBar should not be null");
    }
    bar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME
            | ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO);
    bar.setCustomView(actionBarCustom);

    mActionModeController = new ActionModeController(this);
}

From source file:se.eliga.aves.birddetail.BirdDetailsTabActivity.java

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

    final String latinSpecies = getIntent().getExtras().getString(BirdListFragment.LATIN_SPECIES);
    final String englishSpecies = getIntent().getExtras().getString(BirdListFragment.ENGLISH_SPECIES);
    final String swedishFamily = getIntent().getExtras().getString(BirdListFragment.SWEDISH_FAMILY);

    Bundle bundle = new Bundle(1);
    bundle.putString(BirdSpeciesWebFragment.ENGLISH_SPECIES, englishSpecies);
    bundle.putString(BirdSpeciesXenoCantoPlayerFragment.LATIN_SPECIES, latinSpecies);

    tabHost = (FragmentTabHost) findViewById(android.R.id.tabhost);
    tabHost.setup(this, getSupportFragmentManager(), R.id.tabFrameLayout);

    tabHost.addTab(/*from  w ww  .j  a va  2s .co  m*/
            tabHost.newTabSpec("Wikipedia").setIndicator(getText(R.string.tab_wikipedia),
                    getResources().getDrawable(android.R.drawable.star_on)),
            BirdSpeciesWebFragment.class, bundle);
    tabHost.addTab(
            tabHost.newTabSpec("Flickr").setIndicator(getText(R.string.tab_photos),
                    getResources().getDrawable(android.R.drawable.star_on)),
            BirdSpeciesFlickrGalleryFragment.class, bundle);
    tabHost.addTab(
            tabHost.newTabSpec("xeno-canto").setIndicator(getText(R.string.tab_sounds),
                    getResources().getDrawable(android.R.drawable.star_on)),
            BirdSpeciesXenoCantoPlayerFragment.class, bundle);
    tabHost.addTab(
            tabHost.newTabSpec("Statistik").setIndicator(getText(R.string.tab_facts),
                    getResources().getDrawable(android.R.drawable.star_on)),
            BirdSpeciesFactsFragment.class, bundle);
    tabHost.addTab(tabHost.newTabSpec("Karta").setIndicator(getText(R.string.tab_map),
            getResources().getDrawable(android.R.drawable.star_on)), MapFragment.class, bundle);

    TabWidget tabWidget = (TabWidget) findViewById(android.R.id.tabs);
    LinearLayout linearLayout = (LinearLayout) tabWidget.getParent();
    HorizontalScrollView horizontalScrollView = new HorizontalScrollView(this);
    horizontalScrollView.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT));
    linearLayout.addView(horizontalScrollView, 0);
    linearLayout.removeView(tabWidget);
    horizontalScrollView.addView(tabWidget);
    horizontalScrollView.setHorizontalScrollBarEnabled(false);

    BirdListSpinnerAdapter birdListSpinnerAdapter = createAdapter();
    birdListSpinnerAdapter.setFilterFamily(swedishFamily);
    birdListSpinnerAdapter.initialize(getSharedPreferences(Constants.BIRD_APP_SETTINGS, Context.MODE_PRIVATE));
    if (BirdListAdapter.SortOption.PHYLOGENETIC.equals(birdListSpinnerAdapter.getSortOption())) {
        birdListSpinnerAdapter.setSortOption(BirdListAdapter.SortOption.SWEDISH);
    }

    birdListSpinnerAdapter.refresh();
    birdListSpinnerAdapter.notifyDataSetChanged();

    Spinner spinner = new Spinner(this);
    spinner.setId(R.id.birdspecies_spinner);
    spinner.setAdapter(birdListSpinnerAdapter);
    spinner.setGravity(Gravity.FILL_HORIZONTAL);

    spinner.setSelection(birdListSpinnerAdapter.getPosition(new Bird(latinSpecies)));
    spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> adapterView, View view, int i, long l) {
            BirdSpeciesFragment fragment = (BirdSpeciesFragment) getSupportFragmentManager()
                    .findFragmentByTag(tabHost.getCurrentTabTag());
            Spinner spinner = (Spinner) getActionBar().getCustomView().findViewById(R.id.birdspecies_spinner);
            fragment.loadBird((Bird) spinner.getSelectedItem());
        }

        @Override
        public void onNothingSelected(AdapterView<?> adapterView) {
        }
    });
    getActionBar().setCustomView(spinner);
    getActionBar().setDisplayOptions(
            ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM);

}

From source file:com.docd.purefm.ui.activities.BrowserPagerActivity.java

private void initActionBar() {
    mActionBar = this.getActionBar();
    if (mActionBar == null) {
        throw new RuntimeException("BrowserPagerActivity should have an ActionBar");
    }/*  w ww.jav  a  2s .  c om*/
    mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_CUSTOM
            | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_HOME_AS_UP);

    //noinspection InflateParams
    final View custom = LayoutInflater.from(this).inflate(R.layout.activity_browser_actionbar, null);
    if (custom == null) {
        throw new RuntimeException("Inflated View is null");
    }
    mActionBar.setCustomView(custom);

    mBreadCrumbView = (BreadCrumbTextView) custom.findViewById(R.id.bread_crumb_view);
}

From source file:es.farfuteam.vncpp.controller.NewConnectionActivity.java

/**
 * @param savedInstanceState/*w w  w  . j  a va 2 s.c o  m*/
 * @brief This is the onCreate method
 * @details The onCreate method adds buttons and edittext on the activity
 */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.connection_window);

    ConnectionName_field = (EditText) findViewById(R.id.ConnectionName_inserted);

    IP_field = (EditText) findViewById(R.id.IP_inserted);

    PORT_field = (EditText) findViewById(R.id.PORT_inserted);

    PSW_field = (EditText) findViewById(R.id.PSW_inserted);

    //desplegable seleccion de colores

    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.color_array,
            android.R.layout.simple_spinner_item);

    Spinner_colors = (Spinner) findViewById(R.id.Spinner_colors);

    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

    Spinner_colors.setAdapter(adapter);

    Spinner_colors.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        public void onItemSelected(AdapterView<?> parent, android.view.View v, int position, long id) {
            setColor_format(getPosEnumQuality(position));
        }

        public void onNothingSelected(AdapterView<?> parent) {
            //por defecto se selecciona la posicion 0, 24-bit color(extra-high)
            setColor_format(QualityArray.SuperHigh);
        }
    });

    Button botonConnect = (Button) findViewById(R.id.buttonConnect);
    botonConnect.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            //primero se verifica que los campos se rellenan bien,
            //y se aade a la BD antes de iniciar Canvas.

            if (verify(v)) {

                //crear usuario si todo ha ido bien
                createNewConnection();

                iniCanvasActivity();

            }

        }
    });

    Button botonCancel = (Button) findViewById(R.id.buttonCancel);
    botonCancel.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {

            Cancel(v);

        }
    });

    //efectos del actionBar
    final ActionBar actionBar = getActionBar();

    actionBar.setDisplayOptions(
            ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP);

}

From source file:com.android.calendar.EventInfoActivity.java

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

    // Get the info needed for the fragment
    Intent intent = getIntent();/*from  w w  w  .  java2s. com*/
    int attendeeResponse = 0;
    mEventId = -1;
    boolean isDialog = false;
    ArrayList<ReminderEntry> reminders = null;

    if (icicle != null) {
        mEventId = icicle.getLong(EventInfoFragment.BUNDLE_KEY_EVENT_ID);
        mStartMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_START_MILLIS);
        mEndMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_END_MILLIS);
        attendeeResponse = icicle.getInt(EventInfoFragment.BUNDLE_KEY_ATTENDEE_RESPONSE);
        isDialog = icicle.getBoolean(EventInfoFragment.BUNDLE_KEY_IS_DIALOG);

        reminders = Utils.readRemindersFromBundle(icicle);
    } else if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) {
        mStartMillis = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, 0);
        mEndMillis = intent.getLongExtra(EXTRA_EVENT_END_TIME, 0);
        attendeeResponse = intent.getIntExtra("attendeeStatus", Attendees.ATTENDEE_STATUS_NONE);
        Uri data = intent.getData();
        if (data != null) {
            try {
                List<String> pathSegments = data.getPathSegments();
                int size = pathSegments.size();
                if (size > 2 && "EventTime".equals(pathSegments.get(2))) {
                    // Support non-standard VIEW intent format:
                    // dat =
                    // content://com.android.calendar/events/[id]/EventTime/[start]/[end]
                    mEventId = Long.parseLong(pathSegments.get(1));
                    if (size > 4) {
                        mStartMillis = Long.parseLong(pathSegments.get(3));
                        mEndMillis = Long.parseLong(pathSegments.get(4));
                    }
                } else {
                    mEventId = Long.parseLong(data.getLastPathSegment());
                }
            } catch (NumberFormatException e) {
                if (mEventId == -1) {
                    // do nothing here , deal with it later
                } else if (mStartMillis == 0 || mEndMillis == 0) {
                    // Parsing failed on the start or end time , make sure
                    // the times were not
                    // pulled from the intent's extras and reset them.
                    mStartMillis = 0;
                    mEndMillis = 0;
                }
            }
        }
    }

    if (mEventId == -1) {
        Log.w(TAG, "No event id");
        Toast.makeText(this, R.string.event_not_found, Toast.LENGTH_SHORT).show();
        finish();
    }

    // If we do not support showing full screen event info in this
    // configuration,
    // close the activity and show the event in AllInOne.
    Resources res = getResources();
    if (!res.getBoolean(R.bool.agenda_show_event_info_full_screen)
            && !res.getBoolean(R.bool.show_event_info_full_screen)) {
        CalendarController.getInstance(this).launchViewEvent(mEventId, mStartMillis, mEndMillis,
                attendeeResponse);
        finish();
        return;
    }

    setContentView(R.layout.simple_frame_layout);

    // Get the fragment if exists
    mInfoFragment = (EventInfoFragment) getSupportFragmentManager().findFragmentById(R.id.main_frame);

    // Remove the application title
    ActionBar bar = getActionBar();
    if (bar != null) {
        bar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP);
    }

    // Create a new fragment if none exists
    if (mInfoFragment == null) {
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction ft = fragmentManager.beginTransaction();
        mInfoFragment = new EventInfoFragment(this, mEventId, mStartMillis, mEndMillis, attendeeResponse,
                isDialog,
                (isDialog ? EventInfoFragment.DIALOG_WINDOW_STYLE : EventInfoFragment.FULL_WINDOW_STYLE),
                reminders);
        ft.replace(R.id.main_frame, mInfoFragment);
        ft.commit();
    }
}

From source file:com.xandy.calendar.EventInfoActivity.java

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

    // Get the info needed for the fragment
    Intent intent = getIntent();//from   ww  w. j a va2s.c o m
    int attendeeResponse = 0;
    mEventId = -1;
    boolean isDialog = false;
    ArrayList<ReminderEntry> reminders = null;

    if (icicle != null) {
        mEventId = icicle.getLong(EventInfoFragment.BUNDLE_KEY_EVENT_ID);
        mStartMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_START_MILLIS);
        mEndMillis = icicle.getLong(EventInfoFragment.BUNDLE_KEY_END_MILLIS);
        attendeeResponse = icicle.getInt(EventInfoFragment.BUNDLE_KEY_ATTENDEE_RESPONSE);
        isDialog = icicle.getBoolean(EventInfoFragment.BUNDLE_KEY_IS_DIALOG);

        reminders = Utils.readRemindersFromBundle(icicle);
    } else if (intent != null && Intent.ACTION_VIEW.equals(intent.getAction())) {
        mStartMillis = intent.getLongExtra(EXTRA_EVENT_BEGIN_TIME, 0);
        mEndMillis = intent.getLongExtra(EXTRA_EVENT_END_TIME, 0);
        attendeeResponse = intent.getIntExtra(ATTENDEE_STATUS, Attendees.ATTENDEE_STATUS_NONE);
        Uri data = intent.getData();
        if (data != null) {
            try {
                List<String> pathSegments = data.getPathSegments();
                int size = pathSegments.size();
                if (size > 2 && "EventTime".equals(pathSegments.get(2))) {
                    // Support non-standard VIEW intent format:
                    //dat = content://com.android.calendar/events/[id]/EventTime/[start]/[end]
                    mEventId = Long.parseLong(pathSegments.get(1));
                    if (size > 4) {
                        mStartMillis = Long.parseLong(pathSegments.get(3));
                        mEndMillis = Long.parseLong(pathSegments.get(4));
                    }
                } else {
                    mEventId = Long.parseLong(data.getLastPathSegment());
                }
            } catch (NumberFormatException e) {
                if (mEventId == -1) {
                    // do nothing here , deal with it later
                } else if (mStartMillis == 0 || mEndMillis == 0) {
                    // Parsing failed on the start or end time , make sure the times were not
                    // pulled from the intent's extras and reset them.
                    mStartMillis = 0;
                    mEndMillis = 0;
                }
            }
        }
    }

    if (mEventId == -1) {
        Log.w(TAG, "No event id");
        Toast.makeText(this, R.string.event_not_found, Toast.LENGTH_SHORT).show();
        finish();
    }

    // If we do not support showing full screen event info in this configuration,
    // close the activity and show the event in AllInOne.
    Resources res = getResources();
    if (!res.getBoolean(R.bool.agenda_show_event_info_full_screen)
            && !res.getBoolean(R.bool.show_event_info_full_screen)) {
        CalendarController.getInstance(this).launchViewEvent(mEventId, mStartMillis, mEndMillis,
                attendeeResponse);
        finish();
        return;
    }

    setContentView(R.layout.simple_frame_layout);

    // Get the fragment if exists
    mInfoFragment = (EventInfoFragment) getSupportFragmentManager().findFragmentById(R.id.main_frame);

    // Remove the application title
    ActionBar bar = getActionBar();
    if (bar != null) {
        bar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_HOME);
    }

    // Create a new fragment if none exists
    if (mInfoFragment == null) {
        FragmentManager fragmentManager = getSupportFragmentManager();
        FragmentTransaction ft = fragmentManager.beginTransaction();
        mInfoFragment = new EventInfoFragment(this, mEventId, mStartMillis, mEndMillis, attendeeResponse,
                isDialog,
                (isDialog ? EventInfoFragment.DIALOG_WINDOW_STYLE : EventInfoFragment.FULL_WINDOW_STYLE),
                reminders);
        ft.replace(R.id.main_frame, mInfoFragment);
        ft.commit();
    }
}

From source file:com.android.email.activity.setup.MailboxSettings.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    // This needs to happen before super.onCreate() since that calls onBuildHeaders()
    mInboxId = getIntent().getIntExtra(EXTRA_INBOX_ID, -1);
    mFoldersUri = getIntent().getParcelableExtra(EXTRA_FOLDERS_URI);
    mType = getIntent().getStringExtra(EXTRA_TYPE);

    if (mFoldersUri != null) {
        getLoaderManager().initLoader(FOLDERS_LOADER_ID, null, new MailboxSettingsFolderLoaderCallbacks());
    }//from  w  ww .  j a v a  2s . co m

    super.onCreate(savedInstanceState);

    // Always show "app up" as we expect our parent to be an Email activity.
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayOptions(ActionBar.DISPLAY_HOME_AS_UP, ActionBar.DISPLAY_HOME_AS_UP);
        // Hide the app icon.
        actionBar.setIcon(android.R.color.transparent);
        actionBar.setDisplayUseLogoEnabled(false);
        if (mType != null && mType.equals(PREFERENCE_SYNC_SETTINGS)) {
            actionBar.setTitle(getString(R.string.mailbox_settings_activity_title));
        } else if (mType != null && mType.equals(PREFERENCE_PER_FOLDER_NOTIFICATIONS)) {
            actionBar.setTitle(getString(R.string.mailbox_notify_settings_activity_title));
        }
    }
}