當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。