本文整理汇总了Java中android.support.v7.app.ActionBar类的典型用法代码示例。如果您正苦于以下问题:Java ActionBar类的具体用法?Java ActionBar怎么用?Java ActionBar使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ActionBar类属于android.support.v7.app包,在下文中一共展示了ActionBar类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: fullScreenMode
import android.support.v7.app.ActionBar; //导入依赖的package包/类
private void fullScreenMode(boolean fullScreen) {
ActionBar actionBar = getSupportActionBar();
isFullScreen = fullScreen;
if(fullScreen) {
if(actionBar != null) {
actionBar.hide();
}
adjustActionBarWrap();
} else {
if(actionBar != null) {
actionBar.show();
}
copyFab.hide();
exitFab.hide();
exitFullScreenFab.hide();
}
SPHelper.save(IS_FULL_SCREEN_COPY,fullScreen);
}
示例2: onCreate
import android.support.v7.app.ActionBar; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mAdapter = new CheesesAdapter();
final ListView listView = (ListView) findViewById(android.R.id.list);
listView.setAdapter(mAdapter);
final ActionBar actionBar = getSupportActionBar();
actionBar.setCustomView(R.layout.search_view);
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM);
final EditText editText = (EditText) actionBar.getCustomView();
editText.addTextChangedListener(mTextWatcher);
editText.requestFocus();
}
示例3: onResume
import android.support.v7.app.ActionBar; //导入依赖的package包/类
@Override
public void onResume() {
super.onResume();
ActionBar actionBar = ActivityUtils.supportToolbarFor(this);
if(actionBar != null){
actionBar.setTitle("likes".equals(getArguments().getString(Extra.FILTER)) ? R.string.like : R.string.shared);
actionBar.setSubtitle(null);
}
new ActivityFeatures.Builder()
.begin()
.setBlockNavigationDrawer(false)
.setStatusBarColored(true)
.build()
.apply(getActivity());
}
示例4: onCreate
import android.support.v7.app.ActionBar; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_postulaciones_activas);
// Setting ViewPager for each Tabs
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager_pa);
setupViewPager(viewPager);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawerpa);
// Adding menu icon to Toolbar
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
VectorDrawableCompat indicator
= VectorDrawableCompat.create(getResources(), R.drawable.ic_menu, getTheme());
indicator.setTint(ResourcesCompat.getColor(getResources(),R.color.white,getTheme()));
supportActionBar.setHomeAsUpIndicator(indicator);
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
}
示例5: handleStateChange
import android.support.v7.app.ActionBar; //导入依赖的package包/类
@Override
public void handleStateChange(@NonNull StateChange traversal, @NonNull final StateChanger.Callback callback) {
Path path = traversal.topNewState();
setTitle(path.getTitle());
ActionBar actionBar = getSupportActionBar();
boolean canGoBack = traversal.getNewState().size() > 1;
actionBar.setDisplayHomeAsUpEnabled(canGoBack);
actionBar.setHomeButtonEnabled(canGoBack);
containerAsStateChanger.handleStateChange(traversal, new StateChanger.Callback() {
@Override
public void stateChangeComplete() {
invalidateOptionsMenu();
callback.stateChangeComplete();
}
});
}
示例6: onCreate
import android.support.v7.app.ActionBar; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.chuck_activity_transaction);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
title = (TextView) findViewById(R.id.toolbar_title);
final ActionBar ab = getSupportActionBar();
ab.setDisplayHomeAsUpEnabled(true);
ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);
if (viewPager != null) {
setupViewPager(viewPager);
}
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
transactionId = getIntent().getLongExtra(ARG_TRANSACTION_ID, 0);
getSupportLoaderManager().initLoader(0, null, this);
}
示例7: onCreate
import android.support.v7.app.ActionBar; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_setting);
ActionBar actionBar = getSupportActionBar();
if(actionBar != null){
actionBar.setTitle(" 设置");
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.drawable.ic_back);
}
if (Build.VERSION.SDK_INT >= 21 && Build.VERSION.SDK_INT <23) {
getWindow().setStatusBarColor(0x22000000);//浅黑
} else if (Build.VERSION.SDK_INT >= 23) {
View decorView = getWindow().getDecorView();
decorView.setSystemUiVisibility(View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR);
getWindow().setStatusBarColor(Color.TRANSPARENT);
}
}
示例8: initToolBar
import android.support.v7.app.ActionBar; //导入依赖的package包/类
/**
* 初始化ToolBar
*
* @param toolbar ToolBar的实例
* @param title 标题
* @param isBack 是否出现返回按钮
*/
public void initToolBar(Toolbar toolbar, String title, boolean isBack) {
toolbar.setTitle(title);
setSupportActionBar(toolbar);
if (isBack) {
try {
ActionBar actionBar = getSupportActionBar();
if (null != actionBar)
actionBar.setDisplayHomeAsUpEnabled(true);
} catch (Exception ex) {
ex.printStackTrace();
}
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
}
}
示例9: onResume
import android.support.v7.app.ActionBar; //导入依赖的package包/类
@Override
public void onResume() {
super.onResume();
Settings.get().ui().notifyPlaceResumed(Place.DIALOGS);
ActionBar actionBar = ActivityUtils.supportToolbarFor(this);
if (actionBar != null) {
actionBar.setTitle(R.string.dialogs);
actionBar.setSubtitle(getArguments().getString(Extra.SUBTITLE));
}
if (getActivity() instanceof OnSectionResumeCallback) {
((OnSectionResumeCallback) getActivity()).onSectionResume(NavigationFragment.SECTION_ITEM_DIALOGS);
}
new ActivityFeatures.Builder()
.begin()
.setBlockNavigationDrawer(false)
.setStatusBarColored(true)
.build()
.apply(getActivity());
}
示例10: onCreate
import android.support.v7.app.ActionBar; //导入依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_detail);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
mToolbar.setTitle("");
mItemDescription = (TextView) findViewById(R.id.text_view_item_description);
mItemPrice = (TextView) findViewById(R.id.text_view_item_price);
final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
setSupportActionBar(mToolbar);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
fab.setOnClickListener(this);
mItemId = getIntent().getIntExtra(INTENT_EXTRA_ITEM, 0);
getSupportLoaderManager().initLoader(PLANT_DETAIL_LOADER, null, this);
}
示例11: onResume
import android.support.v7.app.ActionBar; //导入依赖的package包/类
@Override
public void onResume() {
super.onResume();
if(getActivity() instanceof OnSectionResumeCallback){
((OnSectionResumeCallback)getActivity()).onClearSelection();
}
ActionBar actionBar = ActivityUtils.supportToolbarFor(this);
if(actionBar != null){
actionBar.setSubtitle(null);
actionBar.setTitle(R.string.title_mssages);
}
new ActivityFeatures.Builder()
.begin()
.setBlockNavigationDrawer(false)
.setStatusBarColored(true)
.build()
.apply(getActivity());
}
示例12: onCreateView
import android.support.v7.app.ActionBar; //导入依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(
R.layout.fragment_folders, container, false);
Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
ab.setHomeAsUpIndicator(R.drawable.ic_menu);
ab.setDisplayHomeAsUpEnabled(true);
ab.setTitle(R.string.folders);
recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
fastScroller = (FastScroller) rootView.findViewById(R.id.fastscroller);
mProgressBar = (ProgressBar) rootView.findViewById(R.id.progressBar);
recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
if (getActivity() != null)
new loadFolders().execute("");
return rootView;
}
示例13: selectFavoriteProject
import android.support.v7.app.ActionBar; //导入依赖的package包/类
private void selectFavoriteProject() {
if (!mNoProject) {
mSelectedProfileIndex = getIndexOfFavorite();
IProfile activeProfile = mProfiles.get(mSelectedProfileIndex);
String activeProfileName = activeProfile.getName().getText();
ActionBar bar;
if ((bar = getSupportActionBar()) != null) {
bar.setTitle(activeProfileName);
}
DataEntry.setTableName(activeProfileName);
switchToProjectColors();
}
}
示例14: onCreate
import android.support.v7.app.ActionBar; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Set up the action bar.
final android.support.v7.app.ActionBar actionBar = getSupportActionBar();
actionBar.setNavigationMode(android.support.v7.app.ActionBar.NAVIGATION_MODE_TABS);
SectionsPagerAdapter pageAdapter = new SectionsPagerAdapter(getSupportFragmentManager());
viewPager = (ViewPager) findViewById(R.id.pager);
viewPager.setAdapter(pageAdapter);
viewPager.setOnPageChangeListener(new ViewPager.SimpleOnPageChangeListener() {
@Override
public void onPageSelected(int position) {
actionBar.setSelectedNavigationItem(position);
}
});
for (int i = 0; i < pageAdapter.getCount(); i++) {
getSupportActionBar().addTab(getSupportActionBar().newTab()
.setText(pageAdapter.getPageTitle(i))
.setTabListener(this));
}
}
示例15: init
import android.support.v7.app.ActionBar; //导入依赖的package包/类
private void init(View view) {
unbinder = ButterKnife.bind(this, view);
activity = (AppCompatActivity) getActivity();
activity.setSupportActionBar(toolbar);
ActionBar actionBar = activity.getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(true);
actionBar.setTitle(title);
}
LinearLayoutManager layoutManager
= new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(layoutManager);
recyclerView.addItemDecoration(new DividerItemDecoration(activity, layoutManager.getOrientation()));
recyclerView.setHasFixedSize(true);
recyclerView.setMotionEventSplittingEnabled(false);
recyclerView.setNestedScrollingEnabled(false);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(genreAdapter);
}