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.shafiq.mytwittle.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 w  ww.j  a  v a  2 s  .  co  m
        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()
                + (acc.getSocialNetType() == SocialNetConstant.Type.Appdotnet ? " (App.net)" : " (Twitter)"));
    }
    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: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 . java  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);
}

From source file:cn.jasonlv.siri.activity.MainActivity.java

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

    // ??? ???//from   w  w w.ja  va  2s.  c  om
    musicManager = new MusicManager(getApplicationContext());

    // ??
    initImageLoader(getApplicationContext());

    /* get the installed package list*/
    // ??
    mPackageManager = new NativePackageManager(getApplicationContext());

    // ?
    setVolumeControlStream(AudioManager.STREAM_MUSIC);

    // ?
    mSynthesizer = new Synthesizer(getApplicationContext());

    //mSynthesizer.speak("EDI");

    //  ?
    mContactManager = new ContactsManager(getApplicationContext());

    mContactManager.getContactList();

    // ??
    detactor = new LocationDetactor(getApplicationContext());
    info = detactor.getLocationInfo();

    Log.d("location info", info.lat + ", " + info.lon);

    //for(Object o : mPackageManager.getPackageList()){
    //    System.out.println(o.toString());

    setContentView(R.layout.sdk2_api);

    //txtLog = (TextView) findViewById(R.id.txtLog);
    btn = (ActionButton) findViewById(R.id.btn);

    // ?
    speechRecognizer = SpeechRecognizer.createSpeechRecognizer(this,
            new ComponentName(this, VoiceRecognitionService.class));

    speechRecognizer.setRecognitionListener(this);

    btn.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            SharedPreferences sp = PreferenceManager.getDefaultSharedPreferences(MainActivity.this);
            boolean api = sp.getBoolean("api", false);
            if (api) {
                switch (status) {
                case STATUS_None:
                    start();
                    //btn.setText("?");
                    status = STATUS_WaitingReady;
                    break;
                case STATUS_WaitingReady:
                    cancel();
                    status = STATUS_None;
                    //btn.setText("");
                    break;
                case STATUS_Ready:
                    cancel();
                    status = STATUS_None;
                    //btn.setText("");
                    break;
                case STATUS_Speaking:
                    stop();
                    status = STATUS_Recognition;
                    //btn.setText("");
                    break;
                case STATUS_Recognition:
                    cancel();
                    status = STATUS_None;
                    //btn.setText("");
                    break;
                }
            } else {
                start();
            }
        }
    });

    ActionBar actionBar = getActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setDisplayShowTitleEnabled(true);

    container = (LinearLayout) findViewById(R.id.container);
    scrollView = (ScrollView) findViewById(R.id.scroll);

    scrollView.fullScroll(View.FOCUS_DOWN);
}

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

@Override
protected void onCreate(Bundle savedInstanceState) {

    AccountDescriptor account = getApp().getCurrentAccount();

    Bundle extras = getIntent().getExtras();
    if (extras != null) {
        // Notifications
        String accountKey = extras.getString("account_key");
        String notificationType = extras.getString("notification_type");
        long notificationPostId = extras.getLong("notification_post_id");
        String laneName = extras.getString("lane");
        final String urlToLoad = extras.getString("urlToLoad");

        if (accountKey != null) {
            getIntent().removeExtra("account_key");
            getIntent().removeExtra("notification_type");
            AccountDescriptor notificationAccount = getApp().getAccountByKey(accountKey);

            Notifier.saveLastNotificationActioned(this, accountKey, notificationType, notificationPostId);

            Constant.LaneType notificationLaneType = notificationType.equals(
                    SharedPreferencesConstants.NOTIFICATION_TYPE_MENTION) ? Constant.LaneType.USER_MENTIONS
                            : Constant.LaneType.DIRECT_MESSAGES;

            if (notificationAccount != null) {
                long notificationAccountId = notificationAccount.getId();
                long currentAccountId = account.getId();
                if (notificationAccountId == currentAccountId) {
                    int index = account.getCurrentLaneIndex(notificationLaneType);
                    if (index > -1) {
                        mDefaultLaneOverride = index;
                    }//ww  w  .ja v  a  2  s . co m
                } else {
                    showAccount(notificationAccount, notificationLaneType);
                }
            }
        } else if (laneName != null) {
            getIntent().removeExtra("lane");
            int index = account.getCurrentLaneIndex(Constant.LaneType.valueOf(laneName.trim().toUpperCase()));
            if (index > -1) {
                mDefaultLaneOverride = index;
            }
        } else if (urlToLoad != null) {
            getIntent().removeExtra("urlToLoad");
            AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(this);
            alertDialogBuilder.setMessage(getString(R.string.unknown_intent));
            alertDialogBuilder.setPositiveButton(getString(R.string.yes),
                    new DialogInterface.OnClickListener() {
                        public void onClick(DialogInterface dialog, int id) {
                            Intent viewIntent = new Intent("android.intent.action.VIEW",
                                    Uri.parse(urlToLoad.trim()));
                            startActivity(viewIntent);
                        }
                    });
            alertDialogBuilder.setNegativeButton(getString(R.string.no), new DialogInterface.OnClickListener() {
                public void onClick(DialogInterface dialog, int id) {
                    dialog.cancel();
                }
            });
            alertDialogBuilder.create().show();
        }
    }

    super.onCreate(savedInstanceState);

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

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

    mSpinnerAdapter = new AccountAdapter(this, getApp().getAccounts());

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

    Notifier.setNotificationAlarm(this);

    clearTempFolder();

    cacheFollowers();

    //Launch change log dialog
    final WhatsNewDialog whatsNewDialog = new WhatsNewDialog(this);
    whatsNewDialog.show();
}

From source file:com.inc.playground.playground.MainActivity.java

public void setPlayGroundActionBar() {
    String userLoginId, userFullName, userEmail, userPhoto;
    Bitmap imageBitmap = null;/*from   www  .j a v a2 s  .  c  o m*/
    GlobalVariables globalVariables;
    final ActionBar actionBar = getActionBar();

    final String MY_PREFS_NAME = "Login";
    SharedPreferences prefs = getSharedPreferences(MY_PREFS_NAME, MODE_PRIVATE);
    globalVariables = ((GlobalVariables) this.getApplication());
    if (prefs.getString("userid", null) != null) {
        userLoginId = prefs.getString("userid", null);
        userFullName = prefs.getString("fullname", null);
        userEmail = prefs.getString("emilid", null);
        userPhoto = prefs.getString("picture", null);
        globalVariables.GetCurrentUser().setPhotoUrl(userPhoto);
        actionBar.setCustomView(R.layout.actionbar_custom_view_home);
        actionBar.setDisplayShowTitleEnabled(true);
        actionBar.setDisplayShowCustomEnabled(true);
        actionBar.setDisplayUseLogoEnabled(true);
        actionBar.setDisplayHomeAsUpEnabled(true);

        ImageView logo_image = (ImageView) findViewById(R.id.img_profile_action_bar);
        logo_image.setBackgroundResource(R.drawable.pg_logo2);
        TextView userName = (TextView) findViewById(R.id.email);
        userName.setText(userFullName.replace("%20", "  "));
        ImageView img_profile = (ImageView) findViewById(R.id.profile_image);
        imageBitmap = globalVariables.GetUserPictureBitMap();
        if (imageBitmap == null) {
            Log.i(TAG, "downloading");
            try {
                imageBitmap = new DownloadImageBitmapTask().execute(userPhoto).get();
            } catch (InterruptedException e) {
                e.printStackTrace();
            } catch (ExecutionException e) {
                e.printStackTrace();
            }

        } else {
            Log.i(TAG, "Image found");
        }
        img_profile.setImageBitmap(imageBitmap);

        ImageView notificationBtn = (ImageView) findViewById(R.id.notification_btn);
        notificationBtn.setVisibility(View.VISIBLE);
        notificationBtn.setOnClickListener(new View.OnClickListener() {

            @Override
            public void onClick(View v) {
                Intent iv = new Intent(MainActivity.this, NotificationsList.class);
                startActivity(iv);
                finish();
            }
        });
        TextView notificationNumber = (TextView) findViewById(R.id.notification__numberTxt);
        if (globalVariables.GetNotifications() != null && globalVariables.GetNotifications().size() != 0) {
            notificationNumber.setText(Integer.toString(globalVariables.GetNotifications().size()));
            notificationNumber.setVisibility(View.VISIBLE);
        } else {
            notificationNumber.setVisibility(View.INVISIBLE);
        }

        TextView loginTxt = (TextView) findViewById(R.id.login_txt);
        ImageView loginImg = (ImageView) findViewById(R.id.login_img);
        globalVariables.SetUserPictureBitMap(imageBitmap); // Make the imageBitMap global to all activities to avoid downloading twice
        loginTxt.setText("Logout");
        loginImg.setImageResource(R.drawable.pg_action_lock_close);
        // Register to notifications
        Intent intent = new Intent(this, RegistrationIntentService.class);
        startService(intent);

    }
}

From source file:com.nononsenseapps.notepad.MainActivity.java

private void rightCreate() {
    // Set up navigation (adds nice arrow to icon)
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayShowTitleEnabled(false);
    }//from  w w w .  j  ava2  s  .  c o  m
    if (!resuming) {
        onNewIntent(getIntent());
    }
}

From source file:com.google.samples.apps.iosched.ui.SessionLivestreamActivity.java

/**
 * Load the list of currently live sessions or upcoming live sessions. This
 * populates the Action Bar (either the title or as list navigation.
 *//*from  w ww  .j  av  a  2  s  . c  o m*/
private void loadSessionsList(Cursor data) {
    mLivestreamAdapter.swapCursor(data);
    if (data != null && data.getCount() > 0) {
        mSessionsFound = true;
        final ActionBar actionBar = getActionBar();
        if (data.getCount() == 1) {
            // Just one session on, display title in Action Bar
            if (data.moveToFirst()) {
                actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
                actionBar.setDisplayShowTitleEnabled(true);
                actionBar.setTitle(data.getString(SessionsQuery.TITLE));
            }
        } else if (data.getCount() > 1) {
            // 2+ sessions found, set Action Bar to list navigation (spinner)
            actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
            actionBar.setListNavigationCallbacks(mLivestreamAdapter, this);
            actionBar.setDisplayShowTitleEnabled(false);
            getActionBar().setSelectedNavigationItem(locateSelectedItem(data));
        }
    } else if (mSessionsFound) {
        // Sessions were previously found but no sessions are currently live,
        // adjust query to see if there are any future sessions at all
        mSessionsFound = false;
        final Bundle bundle = new Bundle();
        bundle.putBoolean(LOADER_SESSIONS_ARG, true);
        getLoaderManager().restartLoader(SessionsQuery._TOKEN, bundle, this);
    } else {
        // No sessions live right now and no sessions coming up, get out
        finish();
    }
}

From source file:com.nononsenseapps.notepad.MainActivity.java

private void leftOrTabletCreate(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        // currentListId = savedInstanceState.getLong(CURRENT_LIST_ID);
        listIdToSelect = savedInstanceState.getLong(CURRENT_LIST_ID);
        // currentListPos = savedInstanceState.getInt(CURRENT_LIST_POS);
    }//from  ww w .j  a  va2s .  c o m

    // Set up dropdown navigation
    final ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(false);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

    // Will set cursor in Loader
    // mSpinnerAdapter = new ExtrasCursorAdapter(this,
    // R.layout.actionbar_dropdown_item, null,
    // new String[] { NotePad.Lists.COLUMN_NAME_TITLE },
    // new int[] { android.R.id.text1 }, new int[] { -9, -8 },
    // new int[] { R.string.show_from_all_lists, R.string.error_title });
    mSpinnerAdapter = new SimpleCursorAdapter(this, R.layout.actionbar_dropdown_item, null,
            new String[] { NotePad.Lists.COLUMN_NAME_TITLE }, new int[] { android.R.id.text1 }, 0);

    mSpinnerAdapter.setDropDownViewResource(R.layout.actionbar_dropdown_item);

    // This will listen for navigation callbacks
    actionBar.setListNavigationCallbacks(mSpinnerAdapter, this);

    // setContentView(R.layout.fragment_layout);

    // setUpList();

    mSectionAdapter = new SimpleCursorAdapter(this, R.layout.actionbar_dropdown_item, null,
            new String[] { NotePad.Lists.COLUMN_NAME_TITLE }, new int[] { android.R.id.text1 }, 0);

    mSectionsPagerAdapter = new ListPagerAdapter(this, getFragmentManager(), mSectionAdapter);

    // Set up the ViewPager with the sections adapter.
    mViewPager = (ViewPager) findViewById(R.id.leftFragment);
    mViewPager.setAdapter(mSectionsPagerAdapter);

    mViewPager.setOnPageChangeListener(new OnPageChangeListener() {

        @Override
        public void onPageSelected(int pos) {
            currentListId = mSectionsPagerAdapter.getItemId(pos);
            currentListPos = pos;
            actionBar.setSelectedNavigationItem(pos);
        }

        @Override
        public void onPageScrolled(int arg0, float arg1, int arg2) {

        }

        @Override
        public void onPageScrollStateChanged(int arg0) {

        }
    });

    // Set up navigation list
    // Set a default list to open if one is set
    if (listIdToSelect < 0) {
        listIdToSelect = getAList(this, -1);
        // Select the first note in that list to open also
        noteIdToSelect = getANote(this, listIdToSelect);
    }
    // Handle the intent first, so we know what to possibly select once
    // the
    // loader is finished
    beforeBoot = true;

    if (!resuming) {
        onNewIntent(getIntent());
    }

    getLoaderManager().initLoader(0, null, this);
}

From source file:com.amagi82.kerbalspaceapp.CelestialBodyActivity.java

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

    ActionBar actionBar = getActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setTitle(R.string.app_name);

    mSectionsPagerAdapter = new SectionsPagerAdapter(getSupportFragmentManager());

    // Set up the ViewPager with the sections adapter, passing in the appropriate page
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mViewPager.setAdapter(mSectionsPagerAdapter);
    mViewPager.setCurrentItem(getIntent().getIntExtra(EXTRA_PLANET_ID, 0));
    mViewPager.setOnPageChangeListener(new ViewPager.OnPageChangeListener() {
        // onPageSelected finds the current page. invalidateOptionsMenu() resets the action bar for each page.
        @Override//  w ww  . j a v  a2s .co  m
        public void onPageSelected(int position) {
            mCurrentPage = position;
            invalidateOptionsMenu();
        }

        @Override
        public void onPageScrollStateChanged(int state) {
        }

        @Override
        public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
        }
    });
    // Provides action bar settings on initial page creation
    mCurrentPage = getIntent().getIntExtra(EXTRA_PLANET_ID, 0);
}

From source file:com.shafiq.mytwittle.view.BaseLaneActivity.java

boolean composeReleaseFocus(boolean forceCleanup) {

    boolean result = false;

    if (mCurrentComposeFragment != null && mCurrentComposeFragment.hasFocus()) {
        mCurrentComposeFragment.releaseFocus(true);
        forceCleanup = true;/*from  w  w w.  j a  v  a  2s.co  m*/
        result = true;
    }

    if (forceCleanup) {
        ActionBar actionBar = getActionBar();
        actionBar.setTitle(null);
        actionBar.setDisplayShowTitleEnabled(false);
        invalidateOptionsMenu();
    }
    return result;
}