本文整理汇总了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));
}
示例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<>();
}
示例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);
}
}
示例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);
}
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
}
}
示例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);*/
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}
}
}
示例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;
}
});
}