Example usage for android.app ActionBar setDisplayShowTitleEnabled

List of usage examples for android.app ActionBar setDisplayShowTitleEnabled

Introduction

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

Prototype

public abstract void setDisplayShowTitleEnabled(boolean showTitle);

Source Link

Document

Set whether an activity title/subtitle should be displayed.

Usage

From source file:com.owo.android.mtPlease.MainActivity.java

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

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

    // setting for the sidedrawer
    // set the content view
    setBehindContentView(R.layout.drawer_search);
    getSlidingMenu().setFadeEnabled(true);
    getSlidingMenu().setShadowWidthRes(R.dimen.shadow_width);
    getSlidingMenu().setShadowDrawable(R.drawable.shadow);
    getSlidingMenu().setFadeDegree(0.90f);

    searchDrawerCloseButton = (ImageButton) findViewById(R.id.button_search_drawer_close);
    searchDrawerCloseButton.setOnClickListener(new OnClickListener() {

        @Override//  ww  w . j  a v  a  2s  . com
        public void onClick(View v) {
            // TODO Auto-generated method stub
            getSlidingMenu().showContent();
        }

    });

    // 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);
        }
    });

    //         
    mViewPager.setOffscreenPageLimit(3);

    // 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));
    }

    locationSelectSpinner = (Spinner) findViewById(R.id.spinner_location);
    ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.location_array,
            R.layout.spinner_text);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    locationSelectSpinner.setAdapter(adapter);

    datePickerButton = (Button) findViewById(R.id.button_datepicker);
    datePickerButton.setText(modifiedDate);
    datePickerButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            FragmentManager dialogManager = getFragmentManager();
            CalendarDialogFragment calendarDialogFragment = new CalendarDialogFragment();
            calendarDialogFragment.setParentCaller(CalendarDialogFragment.PARENT_IS_ACTIVITY);
            calendarDialogFragment.show(dialogManager, "calendar_dialog_popped");
        }

    });
    // Activity    emailAddress(SESSION_ID)  MyPageFragment
    // .

    //    
    searchButton = (ImageButton) findViewById(R.id.imageButton_search);
    searchButton.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
            // TODO Auto-generated method stub
            try {
                String region = locationSelectSpinner.getSelectedItem().toString();
                if (region.equals("")) {
                    region = "1";
                } else if (region.equals("")) {
                    region = "2";
                } else {
                    region = "3";
                }

                String people = ((EditText) findViewById(R.id.editText_numberPeople)).getText().toString();

                String[] tmp = (datePickerButton.getText().toString()).split(" ");
                String date = tmp[0].substring(0, 4) + "-" + tmp[1].split("")[0] + "-"
                        + tmp[2].split("")[0];

                String query = "?region=" + region + "&people=" + people + "&date=" + date + "&flag=1";
                sendInfoToFragment(people, 2);
                sendInfoToFragment(query, 0);

                getSlidingMenu().showContent();
            } catch (Exception e) {
                // TODO Auto-generated catch block
                Toast.makeText(getApplicationContext(), "  ", Toast.LENGTH_SHORT);
                e.printStackTrace();
            }
        }

    });

}

From source file:lth.pontus.getResults.MainActivity.java

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    mContext = getApplicationContext();//w w w .j a  v a 2  s .  c  o  m

    // Create the adapter that will return a fragment for each of the three
    // primary sections
    // of the app.
    mAppSectionsPagerAdapter = new AppSectionsPagerAdapter(getSupportFragmentManager());

    // Set up the action bar.
    final ActionBar actionBar = getActionBar();

    actionBar.setDisplayShowHomeEnabled(false);
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setDisplayUseLogoEnabled(false);

    // Specify that the Home/Up button should not be enabled, since there is
    // no hierarchical
    // parent.
    actionBar.setHomeButtonEnabled(false);

    // Specify that we will be displaying tabs in the action bar.
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    exercisel = new ExerciseProvider();
    DateHelper = new DateProvider();
    openDB();

    // Set up the ViewPager, attaching the adapter and setting up a listener
    // for when the
    // user swipes between sections.
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mAppSectionsPagerAdapter);
    mViewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
        @Override
        public void onPageSelected(int position) {
            // When swiping between different app sections, select
            // the corresponding tab.
            // We can also use ActionBar.Tab#select() to do this if
            // we have a reference to the
            // Tab.
            actionBar.setSelectedNavigationItem(position);
        }
    });

    // For each of the sections in the app, add a tab to the action bar.
    for (int i = 0; i < mAppSectionsPagerAdapter.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
        // listener for when this tab is selected.
        Tab a = actionBar.newTab().setIcon(mAppSectionsPagerAdapter.getPageICon(i));
        a.setTabListener(this);

        actionBar.addTab(a);
    }
}

From source file:net.lacolaco.smileessence.activity.MainActivity.java

private void initializeView() {
    ActionBar bar = getActionBar();
    bar.setDisplayShowHomeEnabled(true);
    bar.setDisplayShowTitleEnabled(false);
    bar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    viewPager = (ViewPager) findViewById(R.id.viewPager);
    pagerAdapter = new PageListAdapter(this, viewPager);
    initializePages();/*from  ww  w.  ja  va 2  s.c o m*/
}

From source file:com.example.camera360.ui.ImageDetailActivity.java

@SuppressWarnings("unchecked")
@TargetApi(11)//from   w w  w.  j  a v a2  s. com
@Override
public void onCreate(Bundle savedInstanceState) {
    if (BuildConfig.DEBUG) {
        Utils.enableStrictMode();
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.image_detail_pager);

    arrayList = (ArrayList<HashMap<String, String>>) getIntent().getSerializableExtra(IMAGE_URL);

    // Fetch screen height and width, to use as our max size when loading
    // images as this
    // activity runs full screen

    baseAnimate = new BaseAnimate();

    final DisplayMetrics displayMetrics = new DisplayMetrics();
    getWindowManager().getDefaultDisplay().getMetrics(displayMetrics);
    final int height = displayMetrics.heightPixels;
    final int width = displayMetrics.widthPixels;

    // For this sample we'll use half of the longest width to resize our
    // images. As the
    // image scaling ensures the image is larger than this, we should be
    // left with a
    // resolution that is appropriate for both portrait and landscape. For
    // best image quality
    // we shouldn't divide by 2, but this will use more memory and require a
    // larger memory
    // cache.
    final int longest = (height > width ? height : width) / 2;

    ImageCache.ImageCacheParams cacheParams = new ImageCache.ImageCacheParams(this, IMAGE_CACHE_DIR);
    cacheParams.setMemCacheSizePercent(0.25f); // Set memory cache to 25% of
    // app memory

    mImageDetailLayout = (FrameLayout) findViewById(R.id.image_detail_layout);

    mImageDetailView = (LinearLayout) findViewById(R.id.image_detail);

    // The ImageFetcher takes care of loading images into our ImageView
    // children asynchronously
    mImageFetcher = new ImageFetcher(this, longest);
    mImageFetcher.addImageCache(getSupportFragmentManager(), cacheParams);
    mImageFetcher.setImageFadeIn(false);

    // Set up ViewPager and backing adapter
    mAdapter = new ImagePagerAdapter(getSupportFragmentManager(), arrayList.size());

    mInflater = LayoutInflater.from(mImageDetailLayout.getContext());

    mPager = (ViewPager) findViewById(R.id.view_pager);
    mPager.setAdapter(mAdapter);
    mPager.setPageMargin((int) getResources().getDimension(R.dimen.image_detail_pager_margin));
    mPager.setOffscreenPageLimit(2);

    // Set up activity to go full screen
    getWindow().addFlags(LayoutParams.FLAG_FULLSCREEN);

    // Enable some additional newer visibility and ActionBar features to
    // create a more
    // immersive photo viewing experience
    if (Utils.hasHoneycomb()) {
        final ActionBar actionBar = getActionBar();

        // Hide title text and set home as up
        actionBar.setDisplayShowTitleEnabled(false);
        actionBar.setDisplayHomeAsUpEnabled(true);

        // Hide and show the ActionBar as the visibility changes
        mPager.setOnSystemUiVisibilityChangeListener(new View.OnSystemUiVisibilityChangeListener() {
            @Override
            public void onSystemUiVisibilityChange(int vis) {
                if ((vis & View.SYSTEM_UI_FLAG_LOW_PROFILE) != 0) {
                    actionBar.hide();
                } else {
                    actionBar.show();
                }
            }
        });

        // Start low profile mode and hide ActionBar
        mPager.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LOW_PROFILE);
        actionBar.hide();
    }

    // Set the current item based on the extra passed in to this activity
    final int extraCurrentItem = getIntent().getIntExtra(EXTRA_IMAGE, -1);

    currentIndex = extraCurrentItem;

    if (extraCurrentItem != -1) {
        mPager.setCurrentItem(extraCurrentItem);
    }

    mPager.setOnPageChangeListener(new ImageOnPageChangeListener());

    initHeaderMenu();

    addFooterMenu();

    initImageDetail();

    setImageInfo();
}

From source file:com.cairoconfessions.MainActivity.java

public void restoreActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);
    if (mTitle != "Cairo Confessions")
        actionBar.setTitle(mTitle);/*  ww w. j  ava  2s  .c  o  m*/
}

From source file:fr.tvbarthel.attempt.googlyzooapp.MainActivity.java

public void restoreActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(mTitle);// w w w  .  jav a  2  s  . c  om
    actionBar.setIcon(mActionBarIcon);
}

From source file:com.example.office.ui.Office365DemoActivity.java

/**
 * Initializes activity UI elements./*from   ww  w .j a  v  a2 s .co m*/
 */
private void initUi() {
    if (!mIsInitialized) {
        setContentView(R.layout.main_activity);

        mTitle = mDrawerTitle = getTitle();

        // Setting up Action Bar and Tabs.
        ActionBar actionBar = getActionBar();
        actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setLogo(R.drawable.ic_action_mail);

        Tab tab = actionBar.newTab().setText(UI.Screen.CONTACTS.getName(this))
                .setTag(UI.Screen.CONTACTS.getName(this)).setTabListener(new TabListener<ContactsFragment>(this,
                        UI.Screen.CONTACTS.getName(this), ContactsFragment.class));
        actionBar.addTab(tab);

        tab = actionBar.newTab().setText(UI.Screen.MAILBOX.getName(this))
                .setTag(UI.Screen.MAILBOX.getName(this)).setTabListener(new TabListener<DraftsFragment>(this,
                        UI.Screen.MAILBOX.getName(this), DraftsFragment.class));
        actionBar.addTab(tab, true);

        tab = actionBar.newTab().setText(UI.Screen.CALENDAR.getName(this))
                .setTag(UI.Screen.CALENDAR.getName(this)).setTabListener(new TabListener<CalendarFragment>(this,
                        UI.Screen.CALENDAR.getName(this), CalendarFragment.class));
        actionBar.addTab(tab);

        // Setting up sliding drawer.
        mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
        mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, Gravity.START);
        mDrawerList = (ListView) findViewById(R.id.left_drawer);

        SlidingDrawerAdapter drawerAdapter = new SlidingDrawerAdapter(OfficeApplication.getContext(),
                R.layout.drawer_list_item, R.layout.drawer_delimiter);
        mDrawerList.setAdapter(drawerAdapter);

        mDrawerList.setOnItemClickListener(new ListView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                try {
                    Screen[] drawerScreens = ScreenGroup.DRAWER.getMembers().toArray(new Screen[0]);
                    Screen currentScreen = DEFAULT_SCREEN;

                    // use id instead of position here because some positions used by delimiters, id contains real index of clicked item
                    if (drawerScreens != null && drawerScreens.length - 1 >= id) {
                        currentScreen = drawerScreens[(int) id];
                    }
                    switchScreen(currentScreen);
                } catch (Exception e) {
                    Logger.logApplicationException(e, getClass().getSimpleName() + "onItemClick(): Error.");
                }
            }
        });

        actionBar.setHomeButtonEnabled(true);

        // ActionBarDrawerToggle ties together the the proper interactions
        // between the sliding drawer and the action bar app icon
        mDrawerToggle = new ActionBarDrawerToggle(this,
                /* host Activity */mDrawerLayout, /* DrawerLayout object */
                R.drawable.ic_drawer, /* drawer navigation image replacing '<' */
                R.string.drawer_open, R.string.drawer_close) {
            public void onDrawerClosed(View view) {
                getActionBar().setTitle(mTitle);
                invalidateOptionsMenu();
            }

            public void onDrawerOpened(View drawerView) {
                getActionBar().setTitle(mDrawerTitle);
                invalidateOptionsMenu();
            }
        };
        mDrawerLayout.setDrawerListener(mDrawerToggle);
        mIsInitialized = true;
    }

    if (mSavedFragmentTag == null) {
        switchScreen(DEFAULT_SCREEN);
    } else {
        // This is not used mostly as we're going back to this activity when it
        // is at the top of the back stack. So (as it does have 'singleTop' in parameters) it is
        // simply restored and onNewIntent() is called instead of onCreate().
        // So savedInstanceState will usually be null. This is added to anticipate other future use cases.
        switchScreen(Screen.getByTag(mSavedFragmentTag, this));
    }
}

From source file:com.tweetlanes.android.view.HomeActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {

    //StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().penaltyDialog().build());
    //StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
    //StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());

    super.onCreate(savedInstanceState);

    AccountDescriptor account = getApp().getCurrentAccount();

    // Attempt at fixing a crash found in HomeActivity
    if (account == null) {
        Toast.makeText(getApplicationContext(), "No cached account found, restarting",
                Constant.DEFAULT_TOAST_DISPLAY_TIME).show();
        restartApp();//from  ww w.  ja  v a2 s.  c om
        return;
    }

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayUseLogoEnabled(true);
    actionBar.setTitle(null);
    actionBar.setDisplayShowTitleEnabled(false);

    ArrayList<String> adapterList = new ArrayList<String>();
    ArrayList<AccountDescriptor> accounts = getApp().getAccounts();
    for (int i = 0; i < accounts.size(); i++) {
        AccountDescriptor acc = accounts.get(i);
        adapterList.add("@" + acc.getScreenName());
    }
    adapterList.add(getString(R.string.add_account));
    mAdapterStrings = adapterList.toArray(new String[adapterList.size()]);

    mSpinnerAdapter = new ArrayAdapter<String>(getBaseContext(), android.R.layout.simple_spinner_dropdown_item,
            mAdapterStrings);

    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, mOnNavigationListener);
    actionBar.setSelectedNavigationItem(0);

    onCreateNavigationListener();
    configureListNavigation();

    mViewSwitcher = (ViewSwitcher) findViewById(R.id.rootViewSwitcher);
    updateViewVisibility();

    onCreateHandleIntents();

    account.setDisplayedLaneDefinitionsDirty(false);

    configureNotificationService();
}

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 {/*w w  w.ja v  a 2 s .  co m*/
        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  w w w. j  a  v  a  2  s. c  o m
    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);
    }
}