Example usage for android.app ActionBar setDisplayShowCustomEnabled

List of usage examples for android.app ActionBar setDisplayShowCustomEnabled

Introduction

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

Prototype

public abstract void setDisplayShowCustomEnabled(boolean showCustom);

Source Link

Document

Set whether a custom view should be displayed, if set.

Usage

From source file:ch.ethz.coss.nervousnet.hub.ui.SensorDisplayActivity.java

@Override
public void updateActionBar() {

    getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
            WindowManager.LayoutParams.FLAG_FULLSCREEN);
    LayoutInflater inflator = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    View v = inflator.inflate(R.layout.ab_nn, null);
    ActionBar actionBar;
    Switch mainSwitch;//  www.j a  va 2  s  . c o m

    actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(false);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setCustomView(v);
    mainSwitch = (Switch) findViewById(R.id.mainSwitch);

    byte state = ((Application) getApplication()).getState();
    NNLog.d("SensorDisplayActivity", "state = " + state);
    mainSwitch.setChecked(state == 0 ? false : true);

    mainSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override
        public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
            startStopSensorService(isChecked);
        }
    });

}

From source file:com.readystatesoftware.ghostlog.MainActivity.java

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

    Switch mainSwitch = new Switch(this);
    mainSwitch.setChecked(LogService.isRunning());
    mainSwitch.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
        @Override/*from  w w  w .  jav a 2 s .co m*/
        public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
            Intent intent = new Intent(MainActivity.this, LogService.class);
            if (b) {
                if (!LogService.isRunning()) {
                    startService(intent);
                }
            } else {
                stopService(intent);
            }
        }
    });

    final ActionBar bar = getActionBar();
    final ActionBar.LayoutParams lp = new ActionBar.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT,
            ViewGroup.LayoutParams.WRAP_CONTENT);
    lp.gravity = Gravity.RIGHT | Gravity.CENTER_VERTICAL;
    lp.rightMargin = getResources().getDimensionPixelSize(R.dimen.main_switch_margin_right);
    bar.setCustomView(mainSwitch, lp);
    bar.setDisplayShowCustomEnabled(true);

    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (!mPrefs.getBoolean(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES, false)) {
        PreferenceManager.setDefaultValues(this, R.xml.pref_filters, true);
        PreferenceManager.setDefaultValues(this, R.xml.pref_appearance, true);
        SharedPreferences.Editor edit = mPrefs.edit();
        edit.putBoolean(PreferenceManager.KEY_HAS_SET_DEFAULT_VALUES, true);
        edit.apply();
    }

}

From source file:com.bt.download.android.gui.activities.MainActivity.java

private void setupActionBar() {
    ActionBar bar = getActionBar();

    bar.setCustomView(R.layout.view_custom_actionbar);

    bar.setDisplayShowCustomEnabled(true);
    bar.setDisplayHomeAsUpEnabled(true);
    bar.setHomeButtonEnabled(true);//  www  .ja v a  2s.  c om
}

From source file:org.floens.chan.ui.activity.ChanActivity.java

private void updateActionBarStateCallback() {
    final ActionBar actionBar = getActionBar();

    if (threadPane.isSlideable()) {
        if (threadPane.isOpen()) {
            actionBar.setDisplayShowCustomEnabled(true);
            spinnerAdapter.setBoard(boardLoadable.board);
            actionBar.setTitle("");
            pinDrawerListener.setDrawerIndicatorEnabled(true);

            if (boardLoadable.isBoardMode()) {
                setShareUrl(ChanUrls.getBoardUrlDesktop(boardLoadable.board));
            } else if (boardLoadable.isCatalogMode()) {
                setShareUrl(ChanUrls.getCatalogUrlDesktop(boardLoadable.board));
            }/* w  ww.j  a v a  2s. co m*/
        } else {
            actionBar.setDisplayShowCustomEnabled(false);
            actionBar.setTitle(threadLoadable.title);
            pinDrawerListener.setDrawerIndicatorEnabled(false);

            if (threadLoadable.isThreadMode())
                setShareUrl(ChanUrls.getThreadUrlDesktop(threadLoadable.board, threadLoadable.no));
        }
    } else {
        actionBar.setDisplayShowCustomEnabled(true);
        pinDrawerListener.setDrawerIndicatorEnabled(true);
        actionBar.setTitle(threadLoadable.title);

        if (threadLoadable.isThreadMode()) {
            setShareUrl(ChanUrls.getThreadUrlDesktop(threadLoadable.board, threadLoadable.no));
        }
    }

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

    invalidateOptionsMenu();
}

From source file:org.bohrmeista.chan.ui.activity.BoardActivity.java

private void updateActionBarStateCallback() {
    final ActionBar actionBar = getActionBar();

    if (threadPane.isSlideable()) {
        if (threadPane.isOpen()) {
            actionBar.setDisplayShowCustomEnabled(true);
            if (ChanApplication.getBoardManager().getBoardExists(boardLoadable.board)) {
                spinnerAdapter.setCustomBoard(null);
            } else {
                spinnerAdapter.setCustomBoard(boardLoadable.board);
            }/*from   w w w  . j a  v a  2  s .c om*/

            spinnerAdapter.setBoard(boardLoadable.board);

            actionBar.setTitle("");
            pinDrawerListener.setDrawerIndicatorEnabled(true);

            if (boardLoadable.isBoardMode()) {
                setShareUrl(ChanUrls.getBoardUrlDesktop(boardLoadable.board));
            } else if (boardLoadable.isCatalogMode()) {
                setShareUrl(ChanUrls.getCatalogUrlDesktop(boardLoadable.board));
            }
        } else {
            actionBar.setDisplayShowCustomEnabled(false);
            actionBar.setTitle(threadLoadable.title);
            pinDrawerListener.setDrawerIndicatorEnabled(false);

            if (threadLoadable.isThreadMode())
                setShareUrl(ChanUrls.getThreadUrlDesktop(threadLoadable.board, threadLoadable.no));
        }
    } else {
        actionBar.setDisplayShowCustomEnabled(true);
        pinDrawerListener.setDrawerIndicatorEnabled(true);
        actionBar.setTitle(threadLoadable.title);

        if (threadLoadable.isThreadMode()) {
            setShareUrl(ChanUrls.getThreadUrlDesktop(threadLoadable.board, threadLoadable.no));
        }
    }

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

    invalidateOptionsMenu();
}

From source file:org.akvo.caddisfly.ui.activity.MainActivity.java

private void updateActionBarNavigation(int index) {
    if (index == Config.CALIBRATE_SCREEN_INDEX) {
        ActionBar ab = getActionBar();
        assert ab != null;
        ab.setDisplayShowCustomEnabled(true);
        ab.setDisplayShowTitleEnabled(false);
        ab.setDisplayUseLogoEnabled(false);
    } else {/*from ww w . ja  v  a  2 s .  c  om*/
        ActionBar ab = getActionBar();
        assert ab != null;
        ab.setDisplayShowCustomEnabled(false);
        ab.setDisplayShowTitleEnabled(true);
        ab.setDisplayUseLogoEnabled(true);
    }

    switch (index) {
    case Config.SETTINGS_SCREEN_INDEX:
        setTitle(R.string.settings);
        break;
    case Config.HOME_SCREEN_INDEX:
        setTitle(R.string.appName);
        break;
    case Config.SWATCH_SCREEN_INDEX:
        setTitle(R.string.swatches);
        break;

    }
}

From source file:com.linkedin.android.eventsapp.ProfileActivity.java

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

    Bundle extras = getIntent() != null ? getIntent().getExtras() : new Bundle();
    final Person person = extras.getParcelable("person");
    final Activity currentActivity = this;
    final ActionBar bar = getActionBar();
    View viewActionBar = getLayoutInflater().inflate(R.layout.layout_action_bar, null);

    ImageView backView = (ImageView) viewActionBar.findViewById(R.id.actionbar_left);
    backView.setImageResource(R.drawable.arrow_left);
    backView.setVisibility(View.VISIBLE);
    backView.setClickable(true);/*from   www .ja va  2  s  . c  om*/
    backView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            currentActivity.finish();
        }
    });

    ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.MATCH_PARENT);
    bar.setCustomView(viewActionBar, params);
    bar.setDisplayShowCustomEnabled(true);
    bar.setDisplayShowTitleEnabled(false);
    bar.setIcon(new ColorDrawable(Color.TRANSPARENT));
    bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#F15153")));

    TextView attendeeNameView = (TextView) findViewById(R.id.attendeeName);
    attendeeNameView.setText(person.getFirstName() + " " + person.getLastName());

    final ImageView attendeeImageView = (ImageView) findViewById(R.id.attendeeImage);
    final TextView attendeeHeadlineView = (TextView) findViewById(R.id.attendeeHeadline);
    final TextView attendeeLocationView = (TextView) findViewById(R.id.attendeeLocation);

    boolean isAccessTokenValid = LISessionManager.getInstance(currentActivity).getSession().isValid();
    if (isAccessTokenValid) {
        String url = Constants.personByIdBaseUrl + person.getLinkedinId() + Constants.personProjection;
        APIHelper.getInstance(currentActivity).getRequest(currentActivity, url, new ApiListener() {
            @Override
            public void onApiSuccess(ApiResponse apiResponse) {
                try {
                    JSONObject s = apiResponse.getResponseDataAsJson();
                    String headline = s.has("headline") ? s.getString("headline") : "";
                    String pictureUrl = s.has("pictureUrl") ? s.getString("pictureUrl") : null;
                    JSONObject location = s.getJSONObject("location");
                    String locationName = location != null && location.has("name") ? location.getString("name")
                            : "";

                    attendeeHeadlineView.setText(headline);
                    attendeeLocationView.setText(locationName);
                    if (pictureUrl != null) {
                        new FetchImageTask(attendeeImageView).execute(pictureUrl);
                    } else {
                        attendeeImageView.setImageResource(R.drawable.ghost_person);
                    }
                } catch (JSONException e) {

                }

            }

            @Override
            public void onApiError(LIApiError apiError) {

            }
        });

        ViewStub viewOnLIStub = (ViewStub) findViewById(R.id.viewOnLIStub);
        View viewOnLI = viewOnLIStub.inflate();
        Button viewOnLIButton = (Button) viewOnLI.findViewById(R.id.viewOnLinkedInButton);
        viewOnLIButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                DeepLinkHelper.getInstance().openOtherProfile(currentActivity, person.getLinkedinId(),
                        new DeepLinkListener() {
                            @Override
                            public void onDeepLinkSuccess() {

                            }

                            @Override
                            public void onDeepLinkError(LIDeepLinkError error) {

                            }
                        });
            }
        });
    } else {
        attendeeImageView.setImageResource(R.drawable.ghost_person);
    }
}

From source file:com.frostwire.android.gui.activities.MainActivity.java

private void setupActionBar() {
    ActionBar bar = getActionBar();
    if (bar != null) {
        bar.setCustomView(R.layout.view_custom_actionbar);
        bar.setDisplayShowCustomEnabled(true);
        bar.setDisplayHomeAsUpEnabled(true);
        bar.setHomeButtonEnabled(true);/* w  w w.  j a  va2s.  c  o m*/
    }
}

From source file:org.bohrmeista.chan.ui.activity.BoardActivity.java

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

    ChanApplication.getBoardManager().addListener(this);

    boardLoadable = new Loadable();
    threadLoadable = new Loadable();

    boardFragment = ThreadFragment.newInstance(this);
    setBoardFragmentViewMode();/*from   w  w w . j a v a 2s . c o m*/

    threadFragment = ThreadFragment.newInstance(this);

    FragmentTransaction ft = getFragmentManager().beginTransaction();
    ft.replace(R.id.left_pane, boardFragment);
    ft.replace(R.id.right_pane, threadFragment);
    ft.commitAllowingStateLoss();

    final ActionBar actionBar = getActionBar();

    boardSpinner = new Spinner(actionBar.getThemedContext());
    spinnerAdapter = new BoardSpinnerAdapter(this, boardSpinner);
    boardSpinner.setAdapter(spinnerAdapter);
    boardSpinner.setOnItemSelectedListener(this);

    actionBar.setCustomView(boardSpinner);
    actionBar.setDisplayShowCustomEnabled(true);

    updatePaneState();

    Intent startIntent = getIntent();
    Uri startUri = startIntent.getData();

    if (savedInstanceState != null) {
        threadLoadable.readFromBundle(this, "thread", savedInstanceState);
        startLoadingThread(threadLoadable);

        // Reset page etc.
        Loadable tmp = new Loadable();
        tmp.readFromBundle(this, "board", savedInstanceState);
        startLoadingBoard(new Loadable(tmp.board));
    } else {
        if (startUri != null) {
            handleIntentURI(startUri);
        }

        if (boardLoadable.mode == Loadable.Mode.INVALID) {
            List<Board> savedValues = ChanApplication.getBoardManager().getSavedBoards();
            if (savedValues.size() > 0) {
                startLoadingBoard(new Loadable(savedValues.get(0).value));
            }
        }
    }

    if (startIntent.getExtras() != null) {
        handleExtraBundle(startIntent.getExtras());
    }

    ignoreNextOnItemSelected = true;
}

From source file:se.liu.tddd77.bilsensor.MainActivity.java

/**
 * The menu consists of two parts, the record button and the settings. 
 * The record button is a checkable button. The settings is the collection 
 * of the other available options. They should all be added through the 
 * XML-file with the definition of the event here in onOptionsItemSelected.
 *//*  w w  w  .j a  v a 2s  . c o m*/
@Override
public boolean onCreateOptionsMenu(Menu menu) {

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayUseLogoEnabled(false);
    actionBar.setDisplayHomeAsUpEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
    View view = getLayoutInflater().inflate(R.layout.actionbar, null);
    actionBar.setCustomView(view);

    final TextView projectName = (TextView) findViewById(R.id.project_name);
    Log.i("MainActivity", "Getting project name");
    Bundle projectnamebundle = getIntent().getExtras();
    projectname = projectnamebundle.getString("Project_name");
    serverIP = projectnamebundle.getString("Server_IP");
    if (projectname == null) {
        Log.i("MainActivity", "Projectname == null");
    } else {
        Log.i("MainActivity", "Projectname != null");
    }
    Log.i("MainActivity", projectname);
    projectName.setText(projectname);

    final ImageButton button = (ImageButton) findViewById(R.id.recButton);
    button.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            handleRecord(button);
        }
    });
    /*   final ImageButton playButton = (ImageButton) findViewById(R.id.playButton);
       playButton.setOnClickListener(new View.OnClickListener() {
          public void onClick(View v) {
    handlePlay(playButton);
          }
       });*/
    final ImageButton buttonMenu = (ImageButton) findViewById(R.id.menuButton);
    buttonMenu.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            try {
                saveProfile("profil.txt");
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }
    });
    final ImageButton loadMenu = (ImageButton) findViewById(R.id.loadButton);
    loadMenu.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {

            //try {
            //SelectViewNameDialog dialog = new SelectViewNameDialog(avb);
            //dialog.show(getFragmentManager(), null);
            try {
                loadProfile("profil.txt");
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            } catch (BackendError e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

        }
    });

    //playButton.setMaxWidth(playButton.getHeight());

    return super.onCreateOptionsMenu(menu);
}