本文整理汇总了Java中android.support.v7.app.AppCompatActivity.getSupportActionBar方法的典型用法代码示例。如果您正苦于以下问题:Java AppCompatActivity.getSupportActionBar方法的具体用法?Java AppCompatActivity.getSupportActionBar怎么用?Java AppCompatActivity.getSupportActionBar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.app.AppCompatActivity
的用法示例。
在下文中一共展示了AppCompatActivity.getSupportActionBar方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: init
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
private void init(View view) {
unbinder = ButterKnife.bind(this, view);
activity = (AppCompatActivity) getActivity();
activity.setSupportActionBar(toolbar);
animation = AnimationUtils.loadAnimation(activity, R.anim.fade_in);
animation.setDuration(1000);
ActionBar actionBar = activity.getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
}
tryAgainBtn.setOnClickListener(v -> presenter.onPersonDetailRequested(personId));
}
示例2: funtion
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
@Override
protected void funtion() {
background();
setHasOptionsMenu(true);
rv.hasFixedSize();
String ateKey = Helper.getATEKey(getContext());
int colorAccent = Config.accentColor(getContext(), ateKey);
rv.setPopupBgColor(colorAccent);
helper = new Helper(getContext());
AppCompatActivity activity = (AppCompatActivity) getActivity();
if (activity != null && activity.getSupportActionBar() != null){
activity.setSupportActionBar(toolbar);
activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
commonDatabase = new CommonDatabase(getContext(), Constants.Fav_TableName, true);
try {
songList = commonDatabase.readLimit(-1, null);
}finally {
commonDatabase.close();
}
}
示例3: init
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
private void init(View view) {
unbinder = ButterKnife.bind(this, view);
mActivity = (AppCompatActivity) getActivity();
mActivity.setSupportActionBar(toolbar);
ActionBar actionBar = mActivity.getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
}
toolbar.setBackgroundColor(toolbarColor);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mActivity.getWindow().setStatusBarColor(Utils.getDarkColor(toolbarColor));
}
toolbar.setTitle(title);
boolean isTabLayout = Utils.isScreenW(SCREEN_TABLET_DP_WIDTH);
recyclerView.setLayoutManager(setUpLayoutManager(isTabLayout));
recyclerView.setHasFixedSize(true);
recyclerView.setMotionEventSplittingEnabled(false);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(adapter);
}
示例4: funtion
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
@Override
protected void funtion() {
helper = new Helper(getContext());
String ateKey = Helper.getATEKey(getContext());
int colorAccent = Config.accentColor(getContext(), ateKey);
isgridView = true;
rv.setPopupBgColor(colorAccent);
rv.setItemAnimator(new DefaultItemAnimator());
rv.setHasFixedSize(true);
setHasOptionsMenu(true);
background();
toolbar.showOverflowMenu();
songList = new ArrayList<>();
AppCompatActivity activity = (AppCompatActivity) getActivity();
if (activity != null && activity.getSupportActionBar() != null){
activity.setSupportActionBar(toolbar);
activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}
示例5: funtion
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
@Override
protected void funtion() {
CustomLayoutManager customLayoutManager = new CustomLayoutManager(getActivity());
customLayoutManager.setSmoothScrollbarEnabled(true);
rv.setLayoutManager(customLayoutManager);
rv.addItemDecoration(new DividerItemDecoration(getActivity(), 75, false));
playlistViewAdapter = new SongListAdapter(getContext());
playlistViewAdapter.setLayoutId(R.layout.song_list);
playlistViewAdapter.setOnItemClickListener(mOnclick);
rv.setAdapter(playlistViewAdapter);
rv.hasFixedSize();
String ateKey = Helper.getATEKey(getContext());
int colorAccent = Config.accentColor(getContext(), ateKey);
rv.setPopupBgColor(colorAccent);
toolbar.setVisibility(View.VISIBLE);
AppCompatActivity activity = (AppCompatActivity) getActivity();
if (activity != null && activity.getSupportActionBar() != null){
activity.setSupportActionBar(toolbar);
activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
helper = new Helper(getContext());
init();
playList = new ArrayList<>();
}
示例6: styleActionBar
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
public EntityHeaderController styleActionBar(AppCompatActivity activity) {
if (activity == null) {
Log.w(TAG, "No activity, cannot style actionbar.");
return this;
}
final ActionBar actionBar = activity.getSupportActionBar();
if (actionBar == null) {
Log.w(TAG, "No actionbar, cannot style actionbar.");
return this;
}
actionBar.setBackgroundDrawable(
new ColorDrawable(Utils.getColorAttr(activity, R.attr.colorSettings)));
actionBar.setElevation(0);
//if (mRecyclerView != null && mLifecycle != null) {
// ActionBarShadowController.attachToRecyclerView(mActivity, mLifecycle, mRecyclerView);
//}
return this;
}
示例7: initToolbar
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
public Toolbar initToolbar(Toolbar toolbar, String title) {
AppCompatActivity mAppCompatActivity = (AppCompatActivity) mActivity;
toolbar.setTitle(title);
mAppCompatActivity.setSupportActionBar(toolbar);
ActionBar actionBar = mAppCompatActivity.getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(false);
actionBar.setDisplayShowTitleEnabled(false);
}
return toolbar;
}
示例8: setToolbarAsBack
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
public static void setToolbarAsBack(final AppCompatActivity activity, int id, String title) {
Toolbar toolbar = (Toolbar) activity.findViewById(id);
toolbar.setTitle(title);
activity.setSupportActionBar(toolbar);
if (activity.getSupportActionBar() != null) {
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.finish();
}
});
activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
}
示例9: hideActionBar
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
/***
* 隐藏标题栏
*
* @param context 上下文
*/
public static void hideActionBar(@NonNull Context context) {
AppCompatActivity appCompActivity = getAppCompActivity(context);
if (appCompActivity != null) {
ActionBar ab = appCompActivity.getSupportActionBar();
if (ab != null) {
ab.hide();
}
}
scanForActivity(context)
.getWindow()
.setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN);
}
示例10: initToolbar
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
public static Toolbar initToolbar(@NonNull final AppCompatActivity activity, @IdRes int toolbarId, boolean canBack, @Nullable CharSequence title) {
Toolbar toolbar = (Toolbar) activity.findViewById(toolbarId);
if (toolbar == null) {
throw new IllegalStateException(
"The subclass of ToolbarActivity must contain a toolbar.");
}
activity.setSupportActionBar(toolbar);
ActionBar actionBar = activity.getSupportActionBar();
if (actionBar != null) {
if (canBack) {
actionBar.setDisplayHomeAsUpEnabled(true);
if (title != null) {
actionBar.setTitle(title);
} else {
actionBar.setDisplayShowTitleEnabled(false);
}
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
activity.onBackPressed();
}
});
}
}
return toolbar;
}
示例11: init
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
private void init(View view) {
unbinder = ButterKnife.bind(this, view);
mActivity = (AppCompatActivity) getActivity();
mActivity.setSupportActionBar(toolbar);
ActionBar actionBar = mActivity.getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setDisplayShowTitleEnabled(false);
}
toolbar.setBackgroundColor(color);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
mActivity.getWindow().setStatusBarColor(Utils.getDarkColor(color));
}
toolbar.setTitle(title);
LinearLayoutManager layoutManager
= new LinearLayoutManager(getActivity(), LinearLayoutManager.VERTICAL, false);
recyclerView.setLayoutManager(layoutManager);
SnapHelper snapHelper = new GravitySnapHelper(Gravity.TOP);
snapHelper.attachToRecyclerView(recyclerView);
recyclerView.setHasFixedSize(true);
recyclerView.setMotionEventSplittingEnabled(false);
recyclerView.setNestedScrollingEnabled(false);
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.addItemDecoration(new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL));
recyclerView.setAdapter(adapter);
}
示例12: showSystemBar
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
/**
* 显示ActionBar,StatusBar,NavigationBar
*/
@SuppressLint("RestrictedApi")
public static void showSystemBar(final Context context) {
scanForActivity(context).getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
showNavigationBar(context);
AppCompatActivity appCompatActivity = getAppCompActivity(context);
if (appCompatActivity != null) {
ActionBar ab = appCompatActivity.getSupportActionBar();
if (ab != null) {
ab.setShowHideAnimationEnabled(false);
ab.show();
}
}
}
示例13: postApply
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
public static void postApply(@NonNull Activity activity, @Nullable String key) {
if (didPreApply == null)
preApply(activity, key);
performMainTheming(activity, key);
final View rootView = getRootView(activity);
final boolean rootSetsToolbarColor = rootView != null && rootView instanceof ViewInterface &&
((ViewInterface) rootView).setsToolbarColor();
if (!rootSetsToolbarColor && Config.coloredActionBar(activity, key)) {
if (activity instanceof AppCompatActivity) {
final AppCompatActivity aca = (AppCompatActivity) activity;
if (aca.getSupportActionBar() != null) {
ViewProcessor toolbarViewProcessor = getViewProcessor(Toolbar.class);
if (toolbarViewProcessor != null) {
// The processor handles retrieving the toolbar from the support action bar
toolbarViewProcessor.process(activity, key, null, null);
}
}
} else if (activity.getActionBar() != null) {
activity.getActionBar().setBackgroundDrawable(new ColorDrawable(Config.toolbarColor(activity, key, null)));
}
}
if (mPostInflationApply != null) {
synchronized (IGNORE_TAG) {
for (View view : mPostInflationApply) {
if (view instanceof PostInflationApplier)
((PostInflationApplier) view).postApply();
else ATE.themeView(activity, view, key);
}
}
}
if (ATEUtil.isInClassPath(MDUtil.MAIN_CLASS))
MDUtil.initMdSupport(activity, key);
}
示例14: switchfragment
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
public static void switchfragment(AppCompatActivity activity, View container, Fragment fragment, String toolbarTitle) throws Resources.NotFoundException {
if (activity.getSupportActionBar() != null)
activity.getSupportActionBar().setTitle(toolbarTitle);
FragmentTransaction transaction = activity.getSupportFragmentManager().beginTransaction();
transaction.replace(container.getId(), fragment);
transaction.commit();
}
示例15: getSmartBarHeight
import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
private static int getSmartBarHeight(AppCompatActivity activity) {
ActionBar actionbar = activity.getSupportActionBar();
if (actionbar != null)
try {
Class c = Class.forName("com.android.internal.R$dimen");
Object obj = c.newInstance();
Field field = c.getField("mz_action_button_min_height");
int height = Integer.parseInt(field.get(obj).toString());
return activity.getResources().getDimensionPixelSize(height);
} catch (Exception e) {
e.printStackTrace();
actionbar.getHeight();
}
return 0;
}