本文整理匯總了Java中android.app.ActionBar.setTitle方法的典型用法代碼示例。如果您正苦於以下問題:Java ActionBar.setTitle方法的具體用法?Java ActionBar.setTitle怎麽用?Java ActionBar.setTitle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.app.ActionBar
的用法示例。
在下文中一共展示了ActionBar.setTitle方法的11個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setTitle
import android.app.ActionBar; //導入方法依賴的package包/類
@TargetApi(11)
public static void setTitle(ActionBar actionBar, SpannableString spannableString) {
// BUGFIX
// @see http://stackoverflow.com/questions/7658725/android-java-lang-illegalargumentexception-invalid-payload-item-type
if (Build.VERSION.SDK_INT == Build.VERSION_CODES.JELLY_BEAN && Build.MANUFACTURER.toUpperCase().equals("LGE")) {
actionBar.setTitle(spannableString.toString());
} else {
actionBar.setTitle(spannableString);
}
}
示例2: onCreateOptionsMenu
import android.app.ActionBar; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
ActionBar actionBar = getActivity().getActionBar();
if (actionBar != null) {
actionBar.setTitle(R.string.notification_settings);
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
示例3: onCreateOptionsMenu
import android.app.ActionBar; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
ActionBar actionBar = getActivity().getActionBar();
if (actionBar != null) {
actionBar.setTitle(R.string.server_settings);
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
示例4: onCreateOptionsMenu
import android.app.ActionBar; //導入方法依賴的package包/類
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
ActionBar actionBar = getActivity().getActionBar();
if (actionBar != null) {
actionBar.setTitle(R.string.activity_name);
actionBar.setDisplayHomeAsUpEnabled(false);
}
}
示例5: toggleSelection
import android.app.ActionBar; //導入方法依賴的package包/類
void toggleSelection(ActionBar actionBar, int position, String packageName) {
if (mSelections.contains(packageName)) {
mSelections.remove(packageName);
} else {
mSelections.add(packageName);
}
if (!mSelections.isEmpty()) {
actionBar.setTitle(String.valueOf(mSelections.size()) + mContext.getString(R.string.hide_app_selected));
} else {
actionBar.setTitle(mContext.getString(R.string.hidden_app));
}
notifyItemChanged(position);
}
示例6: initActionBar
import android.app.ActionBar; //導入方法依賴的package包/類
protected void initActionBar(){
ActionBar ab = getActionBar();
if (ab!=null)
{
ab.setTitle(getString(R.string.thread_details_activity_title));
ab.setHomeButtonEnabled(true);
}
}
示例7: initActionBar
import android.app.ActionBar; //導入方法依賴的package包/類
protected void initActionBar(){
ActionBar ab = getActionBar();
if (ab!=null)
{
ab.setTitle(getString(R.string.pick_friends));
ab.setHomeButtonEnabled(true);
}
}
示例8: onActivityCreated
import android.app.ActionBar; //導入方法依賴的package包/類
/** This is where we perform additional setup for the fragment that's either
* not related to the fragment's layout or must be done after the layout is drawn.
*/
@Override
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
// Set member variable for whether this fragment is the only one in the activity
Fragment listFragment = getFragmentManager().findFragmentById(R.id.titles_frag);
mSoloFragment = listFragment == null ? true : false;
if (mSoloFragment) {
// The fragment is alone, so enable up navigation
getActivity().getActionBar().setDisplayHomeAsUpEnabled(true);
// Must call in order to get callback to onOptionsItemSelected()
setHasOptionsMenu(true);
}
// Current position and UI visibility should survive screen rotations.
if (savedInstanceState != null) {
setSystemUiVisible(savedInstanceState.getBoolean("systemUiVisible"));
if (mSoloFragment) {
// Restoring these members is not necessary when this fragment
// is combined with the TitlesFragment, because when the TitlesFragment
// is restored, it selects the appropriate item and sends the event
// to the updateContentAndRecycleBitmap() method itself
mCategory = savedInstanceState.getInt("category");
mCurPosition = savedInstanceState.getInt("listPosition");
updateContentAndRecycleBitmap(mCategory, mCurPosition);
}
}
if (mSoloFragment) {
String title = Directory.getCategory(mCategory).getEntry(mCurPosition).getName();
ActionBar bar = getActivity().getActionBar();
bar.setTitle(title);
}
}
示例9: onCreate
import android.app.ActionBar; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.recyclerview);
recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setTitle("RecyclerView");
}
}
// Layout Managers:
recyclerView.setLayoutManager(new LinearLayoutManager(this));
// Item Decorator:
recyclerView.addItemDecoration(new DividerItemDecoration(getResources().getDrawable(R.drawable.divider)));
recyclerView.setItemAnimator(new DefaultItemAnimator());
// Adapter:
String[] adapterData = new String[]{"Alabama", "Alaska", "Arizona", "Arkansas", "California", "Colorado", "Connecticut", "Delaware", "Florida", "Georgia", "Hawaii", "Idaho", "Illinois", "Indiana", "Iowa", "Kansas", "Kentucky", "Louisiana", "Maine", "Maryland", "Massachusetts", "Michigan", "Minnesota", "Mississippi", "Missouri", "Montana", "Nebraska", "Nevada", "New Hampshire", "New Jersey", "New Mexico", "New York", "North Carolina", "North Dakota", "Ohio", "Oklahoma", "Oregon", "Pennsylvania", "Rhode Island", "South Carolina", "South Dakota", "Tennessee", "Texas", "Utah", "Vermont", "Virginia", "Washington", "West Virginia", "Wisconsin", "Wyoming"};
mDataSet = new ArrayList<String>(Arrays.asList(adapterData));
mAdapter = new RecyclerViewAdapter(this, recyclerView, mDataSet);
((RecyclerViewAdapter) mAdapter).setMode(Attributes.Mode.Single);
recyclerView.setAdapter(mAdapter);
try {
new ItemTouchBuilder()
.setList(mDataSet)
.setAdapter(mAdapter)
.setSwappable(false)
.create(recyclerView)
.attachToRecyclerView(recyclerView);
} catch (Exception e) {
e.printStackTrace();
}
}
示例10: onCreate
import android.app.ActionBar; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_attraction_list);
ButterKnife.bind(this, this);
setActionBar(toolbar);
ActionBar actionBar = getActionBar();
if (actionBar != null) {
actionBar.setTitle(getString(R.string.app_title_mm));
}
mAttractionAdapter = new AttractionAdapter(getApplicationContext(), this);
rvAttractions.setAdapter(mAttractionAdapter);
LinearLayoutManager verticalSingleColumnLM = new LinearLayoutManager(getApplicationContext(), LinearLayoutManager.VERTICAL, false);
rvAttractions.setLayoutManager(verticalSingleColumnLM);
mAttractionsModel = ViewModelProviders.of(this).get(AttractionsModel.class);
mAttractionsModel.initDatabase(getApplicationContext());
mAttractionsModel.getAttractions().observe(this, new Observer<List<AttractionVO>>() {
@Override
public void onChanged(@Nullable List<AttractionVO> attractionVOs) {
mAttractionAdapter.setNewData(attractionVOs);
}
});
}
示例11: onCreate
import android.app.ActionBar; //導入方法依賴的package包/類
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
// Get preferences
SharedPreferences preferences =
PreferenceManager.getDefaultSharedPreferences(this);
boolean darkTheme =
preferences.getBoolean(Diary.PREF_DARK_THEME, false);
if (darkTheme)
setTheme(R.style.AppDarkTheme);
// Display the fragment as the main content.
getFragmentManager().beginTransaction()
.replace(android.R.id.content, new SettingsFragment())
.commit();
// Enable back navigation on action bar
ActionBar actionBar = getActionBar();
if (actionBar != null)
{
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(R.string.settings);
}
}