Example usage for android.app ActionBar setDisplayOptions

List of usage examples for android.app ActionBar setDisplayOptions

Introduction

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

Prototype

public abstract void setDisplayOptions(@DisplayOptions int options);

Source Link

Document

Set display options.

Usage

From source file:com.btmura.android.reddit.app.ThingActivity.java

private void setupActionBar() {
    ActionBar bar = getActionBar();
    bar.setDisplayOptions(
            ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP | ActionBar.DISPLAY_SHOW_TITLE);
    refreshTitle(thingBundle.hasLinkId() ? thingBundle.getLinkTitle() : thingBundle.getTitle());
}

From source file:org.jraf.android.bikey.app.ride.edit.RideEditActivity.java

private void setupActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    View customActionBarView = getLayoutInflater().inflate(R.layout.ride_edit_actionbar, null);
    actionBar.setCustomView(customActionBarView, new ActionBar.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT,
            ViewGroup.LayoutParams.MATCH_PARENT));

    View btnDone = customActionBarView.findViewById(R.id.actionbar_done);
    btnDone.setOnClickListener(new OnClickListener() {
        @Override/*  w w  w .j  av a  2 s . co  m*/
        public void onClick(View v) {
            saveRide();
        }
    });

    View btnDiscard = customActionBarView.findViewById(R.id.actionbar_discard);
    btnDiscard.setOnClickListener(new OnClickListener() {
        @Override
        public void onClick(View v) {
            finish();
        }
    });
}

From source file:com.docd.purefm.settings.SettingsActivity.java

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

    final ActionBar actionBar = getActionBar();
    if (actionBar == null) {
        throw new RuntimeException("Should have ActionBar");
    }/*from   w  w  w.ja  v a2  s  .  c  om*/
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_HOME_AS_UP
            | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_USE_LOGO);
}

From source file:fr.cph.stock.android.activity.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    Log.v(TAG, "MainActivity onCreate");
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);//from w  w w . j ava2s . co m

    Bundle b = getIntent().getExtras();
    portfolio = b.getParcelable("portfolio");

    ada = new MainListAdapter(this, portfolio);
    listView = (ListView) findViewById(R.id.mainList);
    listView.setAdapter(ada);
    listView.setOnItemClickListener(new OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> arg0, View arg1, int position, long arg3) {
            Intent intent;
            switch (position) {
            case 0:
                intent = new Intent(getBaseContext(), AccountActivity.class);
                intent.putExtra("portfolio", portfolio);
                startActivityForResult(intent, MainActivity.ACCOUNT_REQUEST);
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                break;
            case 1:
                intent = new Intent(getBaseContext(), EquityActivity.class);
                intent.putExtra("portfolio", portfolio);
                startActivityForResult(intent, MainActivity.EQUITY_REQUEST);
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                break;
            case 2:
                intent = new Intent(getBaseContext(), OverallActivity.class);
                intent.putExtra("portfolio", portfolio);
                startActivityForResult(intent, MainActivity.OVERALL_REQUEST);
                overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);
                break;
            }
        }

    });

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(
            ActionBar.DISPLAY_SHOW_HOME | ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_SHOW_CUSTOM);

    errorView = (TextView) findViewById(R.id.errorMessage);
    errorView.setOnClickListener(new ErrorMainOnClickListener(listView, errorView));
    EasyTracker.getInstance().setContext(this);

    // Set context
    EasyTracker.getInstance().setContext(getApplicationContext());
    // Instantiate the Tracker
    tracker = EasyTracker.getTracker();
}

From source file:com.fihtdc.smartbracelet.activity.FaceBookSettingActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.login_fragment_activity);
    FragmentManager fragmentManager = getSupportFragmentManager();
    userSettingsFragment = (FacebookSettingsFragment) fragmentManager.findFragmentById(R.id.login_fragment);
    mActionBarCustomView = getLayoutInflater().inflate(R.layout.action_bar_custom, null);
    final ActionBar bar = getActionBar();
    bar.setCustomView(mActionBarCustomView,
            new ActionBar.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT));
    bar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    userSettingsFragment.setSessionStatusCallback(new Session.StatusCallback() {
        @Override/*from w w  w.j  av a  2s .c  o m*/
        public void call(Session session, SessionState state, Exception exception) {
            Log.d("LoginUsingLoginFragmentActivity", String.format("New session state: %s", state.toString()));
        }
    });
    mLeft = (ImageView) mActionBarCustomView.findViewById(R.id.left);
    mTitle = (TextView) mActionBarCustomView.findViewById(R.id.middle);
    mRight = (ImageView) mActionBarCustomView.findViewById(R.id.right);
    mLeft.setImageResource(R.drawable.ic_menu_back);
    mRight.setImageResource(R.drawable.ic_menu_home);
    mLeft.setOnClickListener(this);
    mRight.setOnClickListener(this);
    mTitle.setText(getTitle());
}

From source file:htw.bui.openreskit.meter.SeriesActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mOverlayFramelayout = new FrameLayout(this);

    setContentView(mOverlayFramelayout);
    View view = getLayoutInflater().inflate(R.layout.series_fragment, mOverlayFramelayout, false);
    mOverlayFramelayout.addView(view);/*  www .  j  a  va  2  s.  c  o m*/
    mContext = this;
    mHelpView = getLayoutInflater().inflate(R.layout.help_overlay, mOverlayFramelayout, false);

    if (Utils.isTablet(this)) {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_LANDSCAPE);
    } else {
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR_PORTRAIT);
    }

    ActionBar bar = getActionBar();
    bar.setDisplayOptions(
            ActionBar.DISPLAY_SHOW_CUSTOM | ActionBar.DISPLAY_USE_LOGO | ActionBar.DISPLAY_SHOW_TITLE);
    bar.setDisplayShowHomeEnabled(true);

    EnterValueFragment enterValueFrag = (EnterValueFragment) mFragMan
            .findFragmentById(R.id.enter_value_fragment);
    if (enterValueFrag != null) {
        enterValueFrag.getView().setVisibility(View.INVISIBLE);
    }

}

From source file:com.inha.stickyonpage.MainActivity.java

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK) {
        if (getSupportFragmentManager().findFragmentByTag("BrowsingWebView") != null) {
            if (mDrawerLayout.isDrawerOpen(Gravity.RIGHT) || mDrawerLayout.isDrawerOpen(Gravity.LEFT)) {
                mDrawerLayout.closeDrawer(Gravity.RIGHT);
                mDrawerLayout.closeDrawer(Gravity.LEFT);
                return false;
            } else {
                WebView mWebView = (WebView) findViewById(R.id.webView1);
                if (mWebView.canGoBack()) {
                    mWebView.goBack();// w  ww  .  j av  a2 s .c  o m
                } else {
                    ActionBar mActionBar = getActionBar();
                    mActionBar.setCustomView(null);
                    mActionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_HOME);
                    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
                    RecentStickyView stickyFragment = new RecentStickyView();
                    ft.replace(R.id.drawer_main, stickyFragment, "RecentStickyView");
                    ft.commit();
                }
                return false;
            }
        } else if (getSupportFragmentManager().getBackStackEntryCount() == 0) {
            if (!mFlag) {
                Toast.makeText(this, "''?  ?  ?.",
                        Toast.LENGTH_SHORT).show();
                mFlag = true;
                mHandler.sendEmptyMessageDelayed(0, 2000);
                return false;
            } else {
                finish();
            }
        }
    }
    return super.onKeyDown(keyCode, event);
}

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 v a2 s. 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(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.calendar.EventInfoActivity.java

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

    // Get the info needed for the fragment
    Intent intent = getIntent();/*from  www.  j av a  2s.  co  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("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:org.wingy.jp8chan.ui.activity.ImageViewActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_TITLE | ActionBar.DISPLAY_HOME_AS_UP);

    super.onCreate(savedInstanceState);

    if (postAdapter == null) {
        Logger.e(TAG, "Posts in ImageViewActivity was null");
        finish();/*from w  ww . j  av a2  s.c  om*/
        return;
    }

    threadManager = threadManagerStatic;

    ThemeHelper.setTheme(this);

    progressBar = new ProgressBar(this, null, android.R.attr.progressBarStyleHorizontal);
    progressBar.setLayoutParams(new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT,
            FrameLayout.LayoutParams.WRAP_CONTENT));
    progressBar.setProgressDrawable(getResources().getDrawable(R.drawable.progressbar_no_bg));
    progressBar.setIndeterminate(false);
    progressBar.setMax(1000000);

    final FrameLayout decorView = (FrameLayout) getWindow().getDecorView();
    decorView.addView(progressBar);

    progressBar.post(new Runnable() {
        @Override
        public void run() {
            View contentView = decorView.findViewById(android.R.id.content);
            progressBar.setY(contentView.getY() - progressBar.getHeight() / 2);
        }
    });

    // Get the posts with images
    ArrayList<Post> imagePosts = new ArrayList<>();
    for (Post post : postAdapter.getList()) {
        if (post.hasImage) {
            imagePosts.add(post);
        }
    }

    // Setup our pages and adapter
    setContentView(R.layout.image_pager);
    viewPager = (ViewPager) findViewById(R.id.image_pager);
    adapter = new ImageViewAdapter(getFragmentManager(), this);
    adapter.setList(imagePosts);
    viewPager.setAdapter(adapter);
    viewPager.setOnPageChangeListener(this);

    // Select the right image
    for (int i = 0; i < imagePosts.size(); i++) {
        if (imagePosts.get(i).no == selectedId) {
            viewPager.setCurrentItem(i);
            onPageSelected(i);
            break;
        }
    }
}