本文整理汇总了Java中android.support.v7.app.ActionBar.setDisplayHomeAsUpEnabled方法的典型用法代码示例。如果您正苦于以下问题:Java ActionBar.setDisplayHomeAsUpEnabled方法的具体用法?Java ActionBar.setDisplayHomeAsUpEnabled怎么用?Java ActionBar.setDisplayHomeAsUpEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.app.ActionBar
的用法示例。
在下文中一共展示了ActionBar.setDisplayHomeAsUpEnabled方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setTitleBar
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
private void setTitleBar() {
setSupportActionBar(binding.titleToolBar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
//去除默认Title显示
actionBar.setDisplayShowTitleEnabled(false);
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.drawable.icon_back);
// actionBar.setTitle(subjectsBean.getTitle());
// actionBar.setSubtitle("主演:" + StringFormatUtil.formatName(subjectsBean.getCasts()));
}
// title
binding.tvTitle.setText(subjectsBean.getTitle());
// 副标题
binding.tvSubtitle.setText("主演:" + StringFormatUtil.formatName(subjectsBean.getCasts()));
binding.titleToolBar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
}
示例2: initData
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
@Override
protected void initData() {
Bundle bundle = getIntent().getExtras();
if (bundle != null) {
paraMap.put("companyId", bundle.getString("CompanyId"));
if (mToolbar != null) {
setSupportActionBar(mToolbar);
ActionBar mActionBar = getSupportActionBar();
if (mActionBar != null) {
mActionBar.setDisplayHomeAsUpEnabled(true);
mActionBar.setTitle("商机报备 -> " + bundle.getString("CompanyShortName"));
}
}
}
new OpportunityPresenter(this);
presenter.getData(1, SIZE, paraMap);
}
示例3: onCreate
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_request_edit);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeAsUpIndicator(R.drawable.ic_close_white_24dp);
actionBar.setTitle(R.string.title_edit_request);
}
}
示例4: setAllView
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
private void setAllView() {
setContentView(R.layout.activity_edit);
setSupportActionBar((Toolbar) findViewById(R.id.toolbar));
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setHomeButtonEnabled(true);
actionBar.setDisplayHomeAsUpEnabled(true);
}
editListAdapter = new EditListAdapter(this, EditWordMethod.viewExtraWordList(ExtraWordsPath));
RecyclerView recyclerView = findViewById(R.id.list_edit);
recyclerView.setAdapter(editListAdapter);
recyclerView.setItemAnimator(new DefaultItemAnimator());
}
示例5: onCreate
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_list_fragment_view_pager);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle("LIST FRAGMENT VIEWPAGER");
actionBar.setDisplayHomeAsUpEnabled(true);
}
initView();
}
示例6: setupActionBar
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
private void setupActionBar() {
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
// Show the Up button in the action bar.
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
示例7: onCreate
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
ActionBar actionBar = this.getSupportActionBar();
// Set the action bar back button to look like an up button
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
}
示例8: onCreate
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_player);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
toolbar.setNavigationOnClickListener(this);
ActionBar actionBar = getSupportActionBar();
if (null != actionBar) {
actionBar.setDisplayHomeAsUpEnabled(true);
}
mAdapter = new DiscPagerAdapter(getLayoutInflater());
mViewPager.setAdapter(mAdapter);
mDiscChanger = new DiscPageChanger(mViewPager, needle);
mViewPager.addOnPageChangeListener(mDiscChanger);
mPresenter = new PlayerPresenter(this);
mConfigPresenter = new ConfigPresenter(this);
// mPresenter.setPlaylist(id, position);
// ivPlay.setImageResource(PlayerManager.newInstance(this).isPause() ? R.drawable.ic_play : R.drawable.ic_pause);
// setBlurBackground(BitmapFactory.decodeResource(getResources(), R.drawable.play_bg_night));
orders = getResources().getStringArray(R.array.array_music_order);
mPresenter.requestMusicInfo();
mConfigPresenter.requestLoadingList();
}
示例9: initToolBar
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
@Override
public void initToolBar() {
mToolbar.setTitle("");
setSupportActionBar(mToolbar);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
//设置StatusBar透明
SystemBarHelper.immersiveStatusBar(this);
SystemBarHelper.setHeightAndPadding(this, mToolbar);
//设置AppBar展开折叠状态监听
mAppBarLayout.addOnOffsetChangedListener(new AppBarStateChangeEvent() {
@Override
public void onStateChanged(AppBarLayout appBarLayout, State state, int verticalOffset) {
if (state == State.EXPANDED) {
//展开状态
mCollapsingToolbarLayout.setTitle("");
mLineView.setVisibility(View.VISIBLE);
} else if (state == State.COLLAPSED) {
//折叠状态
mCollapsingToolbarLayout.setTitle(name);
mLineView.setVisibility(View.GONE);
} else {
mCollapsingToolbarLayout.setTitle("");
mLineView.setVisibility(View.VISIBLE);
}
}
});
}
示例10: onCreate
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_downloading);
Toolbar toolbar = findViewById(R.id.toolBar);
setSupportActionBar(toolbar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(R.string.downloading);
}
showFragment(new DownloadFragment(), null);
}
示例11: onCreateView
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(
R.layout.fragment_playlist, container, false);
Toolbar toolbar = (Toolbar) rootView.findViewById(R.id.toolbar);
pager = (MultiViewPager) rootView.findViewById(R.id.playlistpager);
recyclerView = (RecyclerView) rootView.findViewById(R.id.recyclerview);
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
final ActionBar ab = ((AppCompatActivity) getActivity()).getSupportActionBar();
ab.setHomeAsUpIndicator(R.drawable.ic_menu);
ab.setDisplayHomeAsUpEnabled(true);
ab.setTitle(R.string.playlists);
playlists = PlaylistLoader.getPlaylists(getActivity(), showAuto);
playlistcount = playlists.size();
if (isDefault) {
initPager();
} else {
initRecyclerView();
}
return rootView;
}
示例12: onCreateView
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.dialog_book_info_read_more, container, false);
Bundle args = getArguments();
String title = args.getString(KEY_DIALOG_FRAGMENT_TITLE, getResources().getString(R.string.authors));
Toolbar toolbar = rootView.findViewById(R.id.toolbar);
toolbar.setTitle(title);
((AppCompatActivity) getActivity()).setSupportActionBar(toolbar);
ActionBar actionBar = ((AppCompatActivity) getActivity()).getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setHomeButtonEnabled(true);
Drawable drawable = getResources()
.getDrawable(R.drawable.ic_close_white_24dp);
drawable = DrawableCompat.wrap(drawable);
DrawableCompat.setTint(drawable, Color.WHITE);
actionBar.setHomeAsUpIndicator(drawable);
}
String body = args.getString(KEY_DIALOG_BODY, getResources().getString(R.string.authors));
TextView bodyTextView = rootView.findViewById(R.id.more_dialog_body_text_view);
bodyTextView.setText(body);
setHasOptionsMenu(true);
return rootView;
}
示例13: onCreate
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_response_details);
ButterKnife.bind(this);
setSupportActionBar(toolbar);
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setDisplayHomeAsUpEnabled(true);
actionBar.setTitle(R.string.title_response_details);
}
}
示例14: initToolBar
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
@Override
public void initToolBar() {
mToolbar.setTitle("番剧详情");
setSupportActionBar(mToolbar);
ActionBar supportActionBar = getSupportActionBar();
if (supportActionBar != null) {
supportActionBar.setDisplayHomeAsUpEnabled(true);
}
// 设置 Toolbar 的透明度
mToolbar.setBackgroundColor(Color.argb(0, 251, 114, 163));
// 设置 StatusBar 的透明度
SystemBarHelper.immersiveStatusBar(this);
SystemBarHelper.setPadding(this, mToolbar);
//获取顶部image高度和toolbar高度
float imageHeight = getResources().getDimension(R.dimen.bangumi_details_top_layout_height);
float toolBarHeight = getResources().getDimension(R.dimen.action_bar_default_height);
mNestedScrollView.setNestedScrollingEnabled(true);
mNestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
public void onScrollChange(NestedScrollView v, int scrollX, int scrollY, int oldScrollX, int oldScrollY) {
// 根据 NestedScrollView 滑动改变 Toolbar 的透明度
float offsetY = toolBarHeight - imageHeight;
//计算滑动距离的偏移量
float offset = 1 - Math.max((offsetY - scrollY) / offsetY, 0f);
float absOffset = Math.abs(offset);
//如果滑动距离大于1就设置完全不透明度
if (absOffset >= 1) {
absOffset = 1;
}
mToolbar.setBackgroundColor(Color.argb((int) (absOffset * 255), 251, 114, 153));
}
});
}
示例15: setupActionBar
import android.support.v7.app.ActionBar; //导入方法依赖的package包/类
/**
* Set up the {@link android.app.ActionBar}, if the API is available.
*/
private void setupActionBar() {
final ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
// Show the Up button in the action bar.
actionBar.setDisplayHomeAsUpEnabled(true);
}
}