本文整理汇总了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);
}
}