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


Java AppCompatActivity.setSupportActionBar方法代码示例

本文整理汇总了Java中android.support.v7.app.AppCompatActivity.setSupportActionBar方法的典型用法代码示例。如果您正苦于以下问题:Java AppCompatActivity.setSupportActionBar方法的具体用法?Java AppCompatActivity.setSupportActionBar怎么用?Java AppCompatActivity.setSupportActionBar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在android.support.v7.app.AppCompatActivity的用法示例。


在下文中一共展示了AppCompatActivity.setSupportActionBar方法的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() {
    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

示例3: 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

示例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.setItemAnimator(new DefaultItemAnimator());
    rv.setPopupBgColor(colorAccent);
    rv.setHasFixedSize(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,代码行数:19,代码来源:RecentlyAddedFragment.java

示例5: setupToolbar

import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
public static boolean setupToolbar(Activity activity) {
    //Not a AppCompatActivity
    if (activity == null || !(activity instanceof AppCompatActivity)) {
        return false;
    }

    //find toolbar and setup, display back button
    AppCompatActivity appCompatActivity = (AppCompatActivity) activity;
    Toolbar toolbar = activity.findViewById(R.id.toolbar);
    if (toolbar != null) {
        appCompatActivity.setSupportActionBar(toolbar);
        appCompatActivity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        return true;
    }

    return false;
}
 
开发者ID:tranleduy2000,项目名称:text_converter,代码行数:18,代码来源:ActivityHelper.java

示例6: initViews

import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
@Override
public void initViews(View view) {
    AppCompatActivity activity = (OpenSourceLicenseActivity) getActivity();
    activity.setSupportActionBar((Toolbar) view.findViewById(R.id.toolbar));
    activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    webView = (WebView) view.findViewById(R.id.web_view);
}
 
开发者ID:makezhao,项目名称:LianXiZhihu,代码行数:8,代码来源:OpenSourceLicenseFragment.java

示例7: 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

示例8: initViews

import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
private void initViews(View view) {
    progressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
    webView = (WebView) view.findViewById(R.id.web_view);
    toolbar = (Toolbar) view.findViewById(R.id.toolbar);
    AppCompatActivity activity = (AppCompatActivity) getActivity();
    activity.setSupportActionBar(toolbar);
    activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    textView = (TextView) view.findViewById(R.id.text_view);
    imageView = (ImageView) view.findViewById(R.id.image_view);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:11,代码来源:InnerBrowserFragment.java

示例9: setData

import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
public void setData() {
    n = NewsUtil.CheckisFavourite(getActivity(), mTitle);
    if (n == 1) {
        n = 0;
        myFavoriteNews.setImageResource(R.drawable.star);
    } else {
        n = 1;
        myFavoriteNews.setImageResource(R.drawable.star_off);

    }

    //Got Advantages why to use Glide over picasso that's why replaced picasso.
    Glide.with(this).load(mUrlToImage)
            .thumbnail(0.1f)
            .error(placeholder)
            .crossFade()
            .diskCacheStrategy(DiskCacheStrategy.SOURCE)
            .skipMemoryCache(true)
            .into(mToolbarImage);
    mTitleText.setText(mTitle);
    mByText.setText(mAuthor);
    mArticleBody.setText(mDescription);
    myFavoriteNews.setContentDescription(getString(R.string.my_favorite_save));
    mTitleText.setContentDescription(getString(R.string.content_desc_title)+mTitle);
    mByText.setContentDescription(getString(R.string.content_desc_author)+mAuthor);
    mArticleBody.setContentDescription(getString(R.string.content_desc_article)+mDescription);
    AppCompatActivity activity = (AppCompatActivity)getActivity();
    // We need to start the enter transition after the data has loaded
    if ( mTransitionAnimation ) {
        activity.supportStartPostponedEnterTransition();

        if ( null != toolbar ) {
            activity.setSupportActionBar(toolbar);

            activity.getSupportActionBar().setDisplayShowTitleEnabled(false);
            activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        }
    }

}
 
开发者ID:vikasdesale,项目名称:News24x7-news-from-every-part-of-the-world,代码行数:41,代码来源:DetailsFragment.java

示例10: initView

import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
private void initView(View view) {
        Toolbar toolbar = (Toolbar) view.findViewById(R.id.setup_toolbar).findViewById(R.id.toolbar);
        final AppCompatActivity parentActivity = (AppCompatActivity) getActivity();
        parentActivity.setSupportActionBar(toolbar);
        parentActivity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        backgroundGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (i == R.id.setup_girl) {
                    backgroundType = PreferenceUtil.GIRL_BACKGROUND;
                } else if (i == R.id.setup_inn) {
                    backgroundType = PreferenceUtil.INN_BACKGROUND;
                } else {
                    backgroundType = PreferenceUtil.TRAN_BACKGROUND;
                }
                if (fromUser) {
                    playBinder.setBackgroundType(backgroundType);
                }
//                initBackgroundType();
            }
        });
//        girlButton.setChecked(true);
/*        tranWhole = view.findViewById(R.id.tran_background_whole);
        girlWhole = view.findViewById(R.id.girl_background_whole);
        innWhole = view.findViewById(R.id.inn_background_whole);

        tranSwitch = (SwitchCompat) view.findViewById(R.id.tran_switch);
        girlSwitch = (SwitchCompat) view.findViewById(R.id.girl_switch);
        innSwitch = (SwitchCompat) view.findViewById(R.id.inn_switch);

        tranWhole.setOnClickListener(this);
        girlWhole.setOnClickListener(this);
        innWhole.setOnClickListener(this);*/



    }
 
开发者ID:Zackratos,项目名称:PureMusic,代码行数:39,代码来源:SetupFragment.java

示例11: onViewCreated

import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);

  ButterKnife.bind(this, view);

  AppCompatActivity activity = (AppCompatActivity) getActivity();
  activity.setSupportActionBar(toolbar);
  activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  activity.getSupportActionBar().setTitle(R.string.fragment_contact_title);
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:11,代码来源:ContactFragment.java

示例12: 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

示例13: onViewCreated

import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
@Override public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
  super.onViewCreated(view, savedInstanceState);

  ButterKnife.bind(this, view);

  AppCompatActivity activity = (AppCompatActivity) getActivity();
  activity.setSupportActionBar(toolbar);
  activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
  activity.getSupportActionBar().setTitle(R.string.fragment_license_title);
}
 
开发者ID:philipphager,项目名称:disclosure-android-app,代码行数:11,代码来源:LicenseFragment.java

示例14: background

import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
@Override
protected void background() {
    songListAdapter.setLayoutId(R.layout.song_list);

    albumListAdapter = new AlbumListAdapter(getContext());
    albumListAdapter.setLayoutID(R.layout.recent_list);

    SnapHelper startSnapHelper = new StartSnapHelper();

    CustomLayoutManager customLayoutManager = new CustomLayoutManager(getContext());
    customLayoutManager.setSmoothScrollbarEnabled(true);
    customLayoutManager.setOrientation(CustomLayoutManager.HORIZONTAL);

    albumrv.setAdapter(albumListAdapter);
    albumrv.setLayoutManager(customLayoutManager);
    albumrv.setHasFixedSize(true);
    albumrv.setNestedScrollingEnabled(false);
    albumrv.setVerticalScrollBarEnabled(false);
    albumrv.setHorizontalScrollBarEnabled(false);
    albumrv.setScrollBarSize(0);
    startSnapHelper.attachToRecyclerView(albumrv);

    CustomLayoutManager c = new CustomLayoutManager(getContext());
    c.setSmoothScrollbarEnabled(true);
    rv.setAdapter(songListAdapter);
    rv.addItemDecoration(new DividerItemDecoration(getContext(), 75, false));
    rv.setLayoutManager(c);
    rv.setHasFixedSize(true);

    songListAdapter.setOnItemClickListener(mOnClick);
    songListAdapter.setOnLongClickListener(onLongClick);
    albumListAdapter.setOnItemClickListener(mOnClickAlbum);

    loadTrak();
    if (((MainActivity) getActivity()) != null) {
        AppCompatActivity appCompatActivity = ((MainActivity) getActivity());
        if (appCompatActivity != null && appCompatActivity.getSupportActionBar() != null) {
            appCompatActivity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
            appCompatActivity.setSupportActionBar(toolbar);
        }
    }
}
 
开发者ID:RajneeshSingh007,项目名称:MusicX-music-player,代码行数:43,代码来源:ArtistFragment.java

示例15: init

import android.support.v7.app.AppCompatActivity; //导入方法依赖的package包/类
private void init(View view) {
    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(fragmentTitle);
    }

    recyclerView.setHasFixedSize(true);
    recyclerView.setMotionEventSplittingEnabled(false);
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.setAdapter(movieListAdapter);
    recyclerView.setLayoutManager(setUpLayoutManager());
    recyclerView.setItemAnimator(new DefaultItemAnimator());
    recyclerView.addOnScrollListener(setupScrollListener(recyclerView.getLayoutManager()));

    tryAgainBtn.setOnClickListener(v -> {
        switch (ID) {
            case 1:
                if (movieListAdapter.isEmpty()) {
                    movieListPresenter.mostPopularListRequested();
                }
                break;
            case 2:
                if (movieListAdapter.isEmpty()) {
                    movieListPresenter.onTopRatedMoviesRequested();
                }
                break;
            case 3:
                if (movieListAdapter.isEmpty()) {
                    movieListPresenter.onBoxOfficeRequested();
                }
                break;
            case 4:
                if(movieListAdapter.isEmpty()) {
                    movieListPresenter.onPopularMovieByGenreRequested(genreId);
                }
                break;
        }
    });

}
 
开发者ID:prakh25,项目名称:MovieApp,代码行数:47,代码来源:MovieListFragment.java


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