当前位置: 首页>>代码示例>>Java>>正文


Java AppCompatActivity.getSupportActionBar方法代码示例

本文整理汇总了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));
}
 
开发者ID:prakh25,项目名称:MovieApp,代码行数:17,代码来源:PeopleDetailFragment.java

示例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();
    }
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:22,代码来源:FavFragment.java

示例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);
    }
 
开发者ID:prakh25,项目名称:MovieApp,代码行数:26,代码来源:MoreImagesFragment.java

示例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);
    }
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:20,代码来源:RecentPlayedFragment.java

示例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<>();
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:25,代码来源:PlaylistFragment.java

示例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;
}
 
开发者ID:Trumeet,项目名称:MiPushFramework,代码行数:20,代码来源:EntityHeaderController.java

示例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;
}
 
开发者ID:Mrqinlei,项目名称:ImitateZHRB,代码行数:12,代码来源:BaseFragment.java

示例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);
    }
}
 
开发者ID:feifadaima,项目名称:https-github.com-hyb1996-NoRootScriptDroid,代码行数:15,代码来源:BaseActivity.java

示例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);
}
 
开发者ID:yangchaojiang,项目名称:yjPlay,代码行数:19,代码来源:VideoPlayUtils.java

示例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;
}
 
开发者ID:z-chu,项目名称:FriendBook,代码行数:28,代码来源:ToolbarHelper.java

示例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);
}
 
开发者ID:prakh25,项目名称:MovieApp,代码行数:28,代码来源:FullCreditFragment.java

示例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();
        }
    }
}
 
开发者ID:dueeeke,项目名称:dkplayer,代码行数:17,代码来源:WindowUtil.java

示例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);
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:39,代码来源:ATE.java

示例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();
}
 
开发者ID:mddanishansari,项目名称:Phlex,代码行数:8,代码来源:Phlex.java

示例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;
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:16,代码来源:ScreenUtil.java


注:本文中的android.support.v7.app.AppCompatActivity.getSupportActionBar方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。