Example usage for android.app ActionBar setTitle

List of usage examples for android.app ActionBar setTitle

Introduction

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

Prototype

public abstract void setTitle(@StringRes int resId);

Source Link

Document

Set the action bar's title.

Usage

From source file:org.tunesremote.LibraryBrowseActivity.java

@SuppressLint("NewApi")
@Override// w w  w .ja v  a 2  s.  c  o m
public void onCreate(Bundle saved) {
    super.onCreate(saved);
    this.prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (this.prefs.getBoolean(this.getString(R.string.pref_fullscreen), true)
            && Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    }
    setContentView(R.layout.act_browse_library);

    artists = new ArtistsListFragment();
    albums = new AllAlbumsListFragment();
    playlists = new PlaylistsFragment();

    isTablet = findViewById(R.id.frame_artists) != null;

    if (!isTablet) {

        (pager = (ViewPager) findViewById(R.id.view_pager))
                .setAdapter(new LibraryPagerAdapter(getSupportFragmentManager()));
        pager.setOnPageChangeListener(this);
        pager.setOffscreenPageLimit(2);
        findViewById(R.id.tab_artists).setSelected(true);

    } else {

        getSupportFragmentManager().beginTransaction().add(R.id.frame_artists, artists)
                .add(R.id.frame_albums, albums).add(R.id.frame_playlists, playlists).commit();
        registerListener(artists, albums, playlists);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);

    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        handler = new TabHandler();
        ActionBar ab = getActionBar();
        ab.setTitle(R.string.control_menu_library);

        if (!isTablet) {
            findViewById(R.id.legacy_tabs).setVisibility(View.GONE);
            ab.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
            Tab artTab = ab.newTab().setText(R.string.control_menu_artists).setTabListener(handler);
            Tab albTab = ab.newTab().setText(R.string.control_menu_albums).setTabListener(handler);
            Tab plyTab = ab.newTab().setText(R.string.control_menu_playlists).setTabListener(handler);
            ab.addTab(artTab);
            ab.addTab(albTab);
            ab.addTab(plyTab);
        }

    }

}

From source file:com.mani.volleydemo.NetworkImageActivity.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
private void actionBarSetup() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
        ActionBar ab = getActionBar();
        ab.setTitle("ImageLoading");
    }/*  w  ww .j  a v a2 s.  c o  m*/
}

From source file:com.albertcbraun.wifidlitedemoapp.fragments.NavigationDrawerFragment.java

/**
 * Per the navigation drawer design guidelines, updates the action bar to show the global app
 * 'context', rather than just what's in the current screen.
 *//* w w w.j av  a2 s.  c o  m*/
private void showGlobalContextActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setTitle(R.string.app_name);
}

From source file:com.gmail.emerssso.srbase.EditSRActivity.java

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

    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setDisplayHomeAsUpEnabled(true);
        actionBar.setTitle(R.string.edit_sr);
    }//from  www . ja v a 2  s. c  om

    mSRNumber = (EditText) findViewById(R.id.SRNumber);
    mCustomer = (EditText) findViewById(R.id.customerName);
    mModelNumber = (EditText) findViewById(R.id.modelNumber);
    mSerialNumber = (EditText) findViewById(R.id.serialNumber);
    mDescription = (EditText) findViewById(R.id.description);
    mBusinessName = (EditText) findViewById(R.id.businessName);
    /* The Daily Button opens a dialog to add a new daily
    associated with this SR. */
    Button mDaily = (Button) findViewById(R.id.add_daily);
    /* The Part Button opens a new dialog to add a new part
    associated with this SR.. */
    Button mPart = (Button) findViewById(R.id.add_part);
    /* The Confirm Button saves the SR to the database. */
    Button mEnter = (Button) findViewById(R.id.confirm);

    Bundle extras = getIntent().getExtras();

    savedUri = (savedInstanceState == null) ? null
            : (Uri) savedInstanceState.getParcelable(SRContentProvider.SR_CONTENT_ITEM_TYPE);

    if (extras != null) {
        savedUri = extras.getParcelable(SRContentProvider.SR_CONTENT_ITEM_TYPE);
        fillData(savedUri);
    }

    if (savedUri != null) {
        myId = savedUri.getLastPathSegment();
    }

    mEnter.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            if (mSRNumber.getText().toString().length() == 0) {
                Toast.makeText(EditSRActivity.this, "SR Number missing", Toast.LENGTH_LONG).show();
            } else {
                saveState();
                setResult(RESULT_OK);
                finish();
            }
        }
    });

    mPart.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            saveState();
            addPart();
        }
    });

    mDaily.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            saveState();
            addDaily();
        }
    });
}

From source file:me.nereo.gztsg.ui.MainActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // setup shadow for drawer
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);
    // setup content modal color
    mDrawerLayout.setScrimColor(Color.argb(100, 0, 0, 0));

    final ActionBar mActionBar = getActionBar();
    // display left to icon
    mActionBar.setDisplayHomeAsUpEnabled(true);
    // enable icon click
    mActionBar.setHomeButtonEnabled(true);
    mActionBar.setDisplayShowTitleEnabled(true);
    mActionBar.setTitle(R.string.app_name);

    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, R.drawable.ic_drawer, R.string.drawer_open,
            R.string.drawer_close) {/* w ww. java2 s . c  om*/

        @Override
        public void onDrawerClosed(View drawerView) {
            mActionBar.setTitle(R.string.app_name);
            // recreate option menu
            invalidateOptionsMenu();
        }

        @Override
        public void onDrawerOpened(View drawerView) {
            mActionBar.setTitle(R.string.setting_title);
            // recreate option menu
            invalidateOptionsMenu();
        }

    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);

    if (savedInstanceState == null) {
        attachSearchBookFragment();
    }

}

From source file:org.catnut.fragment.UserTimelineFragment.java

@Override
public void onStart() {
    super.onStart();
    ActionBar bar = getActivity().getActionBar();
    bar.setIcon(R.drawable.ic_title_list);
    bar.setTitle(mIsMe ? getString(R.string.my_timeline) : getString(R.string.his_timeline, mScreenName));
}

From source file:net.kenevans.android.bleexplorer.DeviceScanActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActionBar actionBar = getActionBar();
    if (actionBar != null) {
        actionBar.setTitle(R.string.title_devices);
    }/*from w w  w.j a v a  2s  .c o m*/
    mHandler = new Handler();

    // Use this check to determine whether BLE is supported on the device.
    // Then you can
    // selectively disable BLE-related features.
    if (!getPackageManager().hasSystemFeature(PackageManager.FEATURE_BLUETOOTH_LE)) {
        Toast.makeText(this, R.string.ble_not_supported, Toast.LENGTH_LONG).show();
        finish();
    }

    // Initializes a Bluetooth adapter. For API level 18 and above, get a
    // reference to BluetoothAdapter through BluetoothManager.
    mBluetoothAdapter = null;
    final BluetoothManager bluetoothManager = (BluetoothManager) getSystemService(Context.BLUETOOTH_SERVICE);
    if (bluetoothManager == null) {
        Toast.makeText(this, R.string.error_bluetooth_manager, Toast.LENGTH_LONG).show();
        finish();
        return;
    }
    try {
        mBluetoothAdapter = bluetoothManager.getAdapter();
    } catch (NullPointerException ex) {
        Toast.makeText(this, R.string.error_bluetooth_adapter, Toast.LENGTH_LONG).show();
    }

    // Checks if Bluetooth is supported on the device.
    if (mBluetoothAdapter == null) {
        String msg = getString(R.string.bluetooth_not_supported);
        Utils.errMsg(this, msg);
        Toast.makeText(this, msg, Toast.LENGTH_LONG).show();
        finish();
    }

    // Set result CANCELED in case the user backs out
    setResult(Activity.RESULT_CANCELED);
}

From source file:org.mars3142.android.toaster.fragment.NavigationDrawerFragment.java

private void showGlobalContextActionBar() {
    ActionBar actionBar = getActionBar();
    actionBar.setDisplayShowTitleEnabled(true);
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_STANDARD);
    actionBar.setTitle(R.string.app_name);
}

From source file:net.kw.shrdlu.grtgtfs.Activities.MenuMapActivity.java

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

    // Make sure we get the correct API key to match the build key.
    if (GRTApplication.isDebugBuild) {
        setContentView(R.layout.mapview_debug);
    } else {/*ww w.j  av  a  2 s.  c  o m*/
        setContentView(R.layout.mapview);
    }

    mMapview = (MapView) findViewById(R.id.mapview);
    mMapview.setBuiltInZoomControls(true);

    mapOverlays = mMapview.getOverlays();

    View mDetailArea = findViewById(R.id.mapview);

    getActionBar().setTitle(R.string.loading_stops);
    getActionBar().setSubtitle(null);

    mMylocation = new MyLocationOverlay(this, mMapview);
    mapOverlays.add(mMylocation);

    mStopsOverlay = new StopsOverlay(mContext);

    // Load up the navigation drawer
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerListView = (ListView) findViewById(R.id.left_drawer);

    mNavAdapter = new NavDrawerListAdapter(mContext, R.layout.drawer_list_item, mDrawerItems);
    mDrawerListView.setAdapter(mNavAdapter);

    mDrawerToggle = new ActionBarDrawerToggle(mContext, mDrawerLayout, R.string.drawer_open,
            R.string.drawer_close) {

        CharSequence savedtitle, savedsubtitle;

        /** Called when a drawer has settled in a completely closed state. */
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            final ActionBar ab = getActionBar();
            if (ab != null) {
                ab.setSubtitle(savedsubtitle);
                ab.setTitle(savedtitle);
            }
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }

        /** Called when a drawer has settled in a completely open state. */
        public void onDrawerOpened(View drawerView) {
            super.onDrawerOpened(drawerView);
            final ActionBar ab = getActionBar();
            if (ab != null) {
                savedtitle = ab.getTitle();
                savedsubtitle = ab.getSubtitle();
                ab.setTitle(R.string.app_name);
                ab.setSubtitle(null);
            }
            invalidateOptionsMenu(); // creates call to onPrepareOptionsMenu()
        }
    };

    // Set the drawer toggle as the DrawerListener
    mDrawerLayout.setDrawerListener(mDrawerToggle);

    mDrawerListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View v, int position, long id) {
            mDrawerLayout.closeDrawers();
            NavOptions.onNavOptionSelected(mContext, mDrawerItems.get(position).getId());
        }
    });

    getActionBar().setHomeButtonEnabled(true);
    getActionBar().setDisplayHomeAsUpEnabled(true);
    mDrawerToggle.setDrawerIndicatorEnabled(false);
}

From source file:com.commonsware.cwac.cam2.support.CameraFragment.java

@Override
public void onHiddenChanged(boolean isHidden) {
    super.onHiddenChanged(isHidden);

    if (!isHidden) {
        ActionBar ab = getActivity().getActionBar();

        ab.setBackgroundDrawable(//from   www .  j  a va2  s.  co  m
                getActivity().getResources().getDrawable(R.drawable.cwac_cam2_action_bar_bg_transparent));
        ab.setTitle("");

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
            ab.setDisplayHomeAsUpEnabled(false);
        } else {
            ab.setDisplayShowHomeEnabled(false);
            ab.setHomeButtonEnabled(false);
        }
    }
}