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:com.swisscom.safeconnect.activity.PipeActivity.java

protected void initActionBar(Activity activity, int stringId, View.OnClickListener listener) {
    ActionBar ab = activity.getActionBar();

    //Tutorial with NoTitle Theme returns null here
    if (ab == null) {
        return;//from w  w  w .j a  v  a  2 s  . c  o  m
    }
    ab.setDisplayShowCustomEnabled(true);
    ab.setDisplayShowTitleEnabled(false);
    ab.setDisplayShowHomeEnabled(false);

    actionBarView = activity.getLayoutInflater().inflate(R.layout.actionbar, null);

    tvTitle = (TextView) actionBarView.findViewById(R.id.tv_title);
    imgBackBtn = (ImageView) actionBarView.findViewById(R.id.img_back_btn);
    if (tvTitle != null && stringId != 0) {
        tvTitle.setText(stringId);
    }

    setOnBackPressedListener(listener);

    ab.setCustomView(actionBarView);
}

From source file:org.noorganization.shoppinglist.view.MainActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    m_presenter = ShoppingListPresenter.getInstance(this);
    if (m_presenter.needsToCreateAList()) {
        m_presenter.createList("Test List");
    }//from w  ww  . j a v  a  2s .  c  o  m

    getWindow().requestFeature(Window.FEATURE_ACTION_BAR);

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_shoppinglist);

    m_listSelector = new Spinner(this);
    m_listSelector.setAdapter(new ListSpinnerAdapter(m_presenter.getLists()));
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setCustomView(m_listSelector);

    updateListDropDown();

    m_listSelector.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() {
        @Override
        public void onItemSelected(AdapterView<?> _parent, View _view, int _position, long _selectedId) {
            m_presenter.selectList((int) _selectedId);
            // TODO refresh listfragments
        }

        @Override
        public void onNothingSelected(AdapterView<?> _parent) {
        }
    });

}

From source file:com.emman.tame.MainActivity.java

public void restoreActionBar() {
    ActionBar actionBar = getActionBar();

    actionBar.setDisplayShowCustomEnabled(true);
    actionBar.setCustomView(R.layout.action_bar);

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(mTitle);//from ww w. j  av a 2 s  .c om
}

From source file:com.numenta.taurus.instance.InstanceListActivity.java

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

    final SharedPreferences pref = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());

    // Create content from resource
    setContentView(R.layout.activity_instance_list);

    // Get ListFragment
    _listFragment = (InstanceListFragment) getFragmentManager().findFragmentById(R.id.instance_list_fragment);

    // Add Filter menu
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setHomeButtonEnabled(false);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setCustomView(R.layout.actionbar_filter);
        _favorites = (RadioGroup) actionBar.getCustomView().findViewById(R.id.filter);
        if (_favorites != null) {
            _favorites.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                @Override//www . j  ava  2  s .  co  m
                public void onCheckedChanged(RadioGroup group, int checkedId) {
                    if (checkedId == R.id.filter_favorites) {
                        clearNotifications();
                        _listFragment.filterFavorites();
                    } else {
                        _listFragment.clearFilter();
                    }
                    // Write the new viewState to the preferences
                    pref.edit().putInt(TaurusPreferenceConstants.PREF_LAST_VIEW_STATE, checkedId).apply();
                }
            });
            int checkedId = R.id.filter_none;
            try {
                checkedId = pref.getInt(TaurusPreferenceConstants.PREF_LAST_VIEW_STATE, R.id.filter_none);
            } catch (ClassCastException e) {
                // Remove old preference value
                pref.edit().remove(TaurusPreferenceConstants.PREF_LAST_VIEW_STATE).apply();
            }
            RadioButton button = (RadioButton) _favorites.findViewById(checkedId);
            if (button != null) {
                button.setChecked(true);
            }
        }
    }
    // Handle search queries
    if (getIntent() != null) {
        handleIntent(getIntent());
    }
    // Check if we should show the tutorial page
    boolean skipTutorial = pref.getBoolean(PreferencesConstants.PREF_SKIP_TUTORIAL, false);
    if (!skipTutorial) {
        Intent myIntent = new Intent(this, TutorialActivity.class);
        startActivity(myIntent);
        overridePendingTransition(0, R.anim.fadeout_animation);
    }

}

From source file:com.example.routerecorder.FragmentTabs.java

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

    instance = this;

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

    //bar.setDisplayShowTitleEnabled(false);
    //bar.setDisplayShowHomeEnabled(false);
    bar.setDisplayShowCustomEnabled(false);

    bar.addTab(bar.newTab().setText("Show Map")
            .setTabListener(new TabListener<RouteMapFragment>(this, "Show Map", RouteMapFragment.class)));

    bar.addTab(bar.newTab().setText("Add Trip")
            .setTabListener(new TabListener<AddRouteFragment>(this, "Add Trip", AddRouteFragment.class)));

    bar.addTab(bar.newTab().setText("Show List")
            .setTabListener(new TabListener<MyListFragment>(this, "Show List", MyListFragment.class)));

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }/*from w  w  w. j a  va 2 s  .  c o m*/

    //FragmentManager manager = getSupportFragmentManager();
    //fragmentA = (RouteMapFragment) manager.findFragmentById(R.id.map);
    //fragmentB = (AddRouteFragment) manager.findFragmentById(R.id.fragment_container);

}

From source file:com.yuya.routerecorder.FragmentTabs.java

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

    instance = this;

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

    //bar.setDisplayShowTitleEnabled(false);
    //bar.setDisplayShowHomeEnabled(false);
    bar.setDisplayShowCustomEnabled(false);

    bar.addTab(bar.newTab().setIcon(R.drawable.world_white)
            .setTabListener(new TabListener<RouteMapFragment>(this, "Show Map", RouteMapFragment.class)));

    bar.addTab(bar.newTab().setIcon(R.drawable.pen_white_frame)
            .setTabListener(new TabListener<AddRouteFragment>(this, "Add Trip", AddRouteFragment.class)));

    bar.addTab(bar.newTab().setIcon(R.drawable.list_new)
            .setTabListener(new TabListener<MyListFragment>(this, "Show List", MyListFragment.class)));

    if (savedInstanceState != null) {
        bar.setSelectedNavigationItem(savedInstanceState.getInt("tab", 0));
    }/*from  w ww  . j av  a  2  s.  co m*/

    //FragmentManager manager = getSupportFragmentManager();
    //fragmentA = (RouteMapFragment) manager.findFragmentById(R.id.map);
    //fragmentB = (AddRouteFragment) manager.findFragmentById(R.id.fragment_container);

}

From source file:com.android.talkback.tutorial.TutorialLessonFragment.java

@Override
public void onResume() {
    super.onResume();
    Activity activity = getActivity();/* w  w w  .jav  a 2s. c  om*/
    if (activity != null) {
        ActionBar actionBar = activity.getActionBar();
        actionBar.setDisplayHomeAsUpEnabled(false);
        actionBar.setDisplayShowHomeEnabled(false);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setCustomView(R.layout.tutorial_action_bar);
        actionBar.getCustomView().findViewById(R.id.up).setOnClickListener(this);
        TextView title = (TextView) actionBar.getCustomView().findViewById(R.id.action_bar_title);
        title.setText(getTitle());
        LocalBroadcastManager.getInstance(activity).registerReceiver(mActionMonitor,
                GestureActionMonitor.FILTER);
    }

    TalkBackService service = TalkBackService.getInstance();
    if (service != null) {
        service.addEventListener(mExercise);
    }
}

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

/**
 * ActionBar/*from   w w w  . j  a  v a  2s . 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:com.linkedin.android.eventsapp.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    pager = new ViewPager(this);
    pager.setId(R.id.pager);/*from   w ww.  ja  v  a 2 s .  co m*/
    pager.setOffscreenPageLimit(5);
    setContentView(pager);

    final ActionBar bar = getActionBar();
    View viewActionBar = getLayoutInflater().inflate(R.layout.layout_action_bar, null);

    TextView textviewTitle = (TextView) viewActionBar.findViewById(R.id.actionbar_textview);
    ActionBar.LayoutParams params = new ActionBar.LayoutParams(ActionBar.LayoutParams.WRAP_CONTENT,
            ActionBar.LayoutParams.MATCH_PARENT, Gravity.CENTER);
    textviewTitle.setText("UPCOMING EVENTS");
    bar.setCustomView(viewActionBar, params);
    bar.setDisplayShowCustomEnabled(true);
    bar.setDisplayShowTitleEnabled(false);
    bar.setIcon(new ColorDrawable(Color.TRANSPARENT));
    bar.setBackgroundDrawable(new ColorDrawable(Color.parseColor("#F15153")));

    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);

    mEventTabsAdapter = new com.linkedin.android.eventsapp.EventTabsAdapter(this, pager);
    SimpleDateFormat ft = new SimpleDateFormat("E dd MMM");
    ArrayList<Event> events = EventsManager.getInstance(this).getEvents();
    for (Event event : events) {
        String eventDay = ft.format(new Date(event.getEventDate()));
        mEventTabsAdapter.addTab(bar.newTab().setText(eventDay), EventFragment.class, event);
    }
}

From source file:com.notriddle.budget.EnvelopesActivity.java

private void setupDrawer() {
    mNavDrawer = (ListView) findViewById(R.id.left_drawer);
    mNavAdapter = new NavAdapter(this);
    mNavDrawer.setAdapter(mNavAdapter);/*  ww w .  j  ava 2  s.c o  m*/
    mNavDrawer.setOnItemClickListener(this);
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mNavToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer,
            R.string.drawerOpen_button, R.string.drawerClose_button) {
        @Override
        public void onDrawerClosed(View v) {
            super.onDrawerClosed(v);
            ActionBar ab = getActionBar();
            ab.setTitle(getTitle());
            invalidateOptionsMenu();
            if (mCustomActionBarView != null) {
                ab.setCustomView(mCustomActionBarView);
                ab.setDisplayShowTitleEnabled(false);
                ab.setDisplayShowCustomEnabled(true);
            }
        }

        @Override
        public void onDrawerSlide(View v, float off) {
            super.onDrawerSlide(v, off);
            int allIn = mColor;
            int allOut = 0xFFEEEEEE;
            int result = Color.rgb((int) (Color.red(allIn) * (1 - off) + Color.red(allOut) * off),
                    (int) (Color.green(allIn) * (1 - off) + Color.green(allOut) * off),
                    (int) (Color.blue(allIn) * (1 - off) + Color.blue(allOut) * off));
            mActionBarColor.setColor(result);
        }

        @Override
        public void onDrawerOpened(View v) {
            super.onDrawerOpened(v);
            ActionBar ab = getActionBar();
            ab.setTitle(getString(R.string.app_name));
            invalidateOptionsMenu();
            if (mCustomActionBarView != null) {
                ab.setDisplayShowTitleEnabled(true);
                ab.setDisplayShowCustomEnabled(false);
                ab.setCustomView(null);
            }
        }
    };
    mDrawerLayout.setDrawerListener(mNavToggle);
    getActionBar().setHomeButtonEnabled(true);
    getActionBar().setDisplayHomeAsUpEnabled(true);
}