本文整理汇总了Java中android.support.v7.widget.Toolbar.setNavigationIcon方法的典型用法代码示例。如果您正苦于以下问题:Java Toolbar.setNavigationIcon方法的具体用法?Java Toolbar.setNavigationIcon怎么用?Java Toolbar.setNavigationIcon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.v7.widget.Toolbar
的用法示例。
在下文中一共展示了Toolbar.setNavigationIcon方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onInitToolbar
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
public void onInitToolbar(Toolbar toolBar, String title, int icon, boolean displayHome) {
if (toolBar != null) {
setSupportActionBar(toolBar);
ActionBar actionBar = getSupportActionBar();
if (actionBar != null) {
actionBar.setTitle(title);
actionBar.setDisplayShowHomeEnabled(displayHome);
actionBar.setDisplayHomeAsUpEnabled(displayHome);
if (icon != -1 && displayHome) {
toolBar.setNavigationIcon(ContextCompat.getDrawable(this, icon));
}
}
}
}
示例2: onCreate
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_manage);
recyclerView_manage = (RecyclerView) findViewById(R.id.recyclerView_manage);
ptrFrame = (PtrClassicFrameLayout) findViewById(R.id.fragment_rotate_header_with_view_group_frame);
initPtrFrame();
toolbar = (Toolbar) findViewById(R.id.toolbar_manage);
toolbar.setNavigationIcon(R.mipmap.button_back);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
toolbar.setTitle("已注册用户");
toolbar.inflateMenu(R.menu.base_toolbar_menu);
StaggeredGridLayoutManager layoutManager = new StaggeredGridLayoutManager(3, StaggeredGridLayoutManager.VERTICAL);
recyclerView_manage.setLayoutManager(layoutManager);
mList = new ArrayList<>();
adapter = new ManageAdapter(mList);
recyclerView_manage.setAdapter(adapter);
}
示例3: initErrorToolbar
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
private void initErrorToolbar() {
mToolbar=(Toolbar)mErrorLayout.findViewById(R.id.toolbar_p);
setSupportActionBar(mToolbar);
mToolbar.setTitle("");
//这里必须设置一个空标题,不然toolbar中的textview标题不居中
mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
int menuItemId = item.getItemId();
if (menuItemId == R.id.action_more) {
Toast.makeText(PersonalHomeActivity.this, "举报", Toast.LENGTH_SHORT).show();
}
return true;
}
});
mToolbar.setNavigationIcon(R.drawable.white_back);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
}
示例4: onCreate
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_music);
Toolbar mToolbar = (Toolbar) findViewById(R.id.toolbar);
mToolbar.setNavigationIcon(R.drawable.back);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
setupListView((ListView) findViewById(R.id.listView));
}
示例5: onCreate
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_teach);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setTitle("修改教程");
setSupportActionBar(toolbar);
toolbar.setNavigationIcon(R.drawable.back);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
init();
ThemeUtils.initStatusBarColor(TeachActivity.this, ThemeUtils.getPrimaryDarkColor(TeachActivity.this));
}
示例6: initToolBar
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
/**
* 初始化toolbar
*/
private void initToolBar(){
mAppBarLayout = (AppBarLayout) findViewById(R.id.main_appbar);
//设置导航图标要在setSupportActionBar方法之后
mToolbar=(Toolbar)findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
//这里必须设置一个空标题,不然toolbar中的textview标题不居中
mToolbar.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
int menuItemId = item.getItemId();
if (menuItemId == R.id.action_more) {
Toast.makeText(PersonalHomeActivity.this, "举报", Toast.LENGTH_SHORT).show();
}
return true;
}
});
mToolbar.setNavigationIcon(R.drawable.white_back);
mToolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
}
示例7: setToolBar
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
public void setToolBar(int toolBarId, ToolBarOptions options) {
toolbar = (Toolbar) findViewById(toolBarId);
if (options.titleId != 0) {
toolbar.setTitle(options.titleId);
}
if (!TextUtils.isEmpty(options.titleString)) {
toolbar.setTitle(options.titleString);
}
if (options.logoId != 0) {
toolbar.setLogo(options.logoId);
}
setSupportActionBar(toolbar);
if (options.isNeedNavigate) {
toolbar.setNavigationIcon(options.navigateId);
toolbar.setContentInsetStartWithNavigation(0);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onNavigateUpClicked();
}
});
}
}
示例8: onCreate
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_event_content);
recyclerView= (RecyclerView) findViewById(R.id.recycler_view);
list=new ArrayList<>();
adapter=new EventAdapter(this,list);
toolbar= (Toolbar) findViewById(R.id.Event_toolbar);
toolbar.setNavigationIcon(R.drawable.backbutton);
toolbar.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
}
});
RecyclerView.LayoutManager layoutManager=new GridLayoutManager(this,2); // 2 is the number of columns in grid view
recyclerView.setLayoutManager(new GridLayoutManager(this,2));
recyclerView.addItemDecoration(new GridSpacingItemDecoration(2,dpToPx(10),true));
recyclerView.setItemAnimator(new DefaultItemAnimator());
recyclerView.setAdapter(adapter);
initialize();
}
示例9: onCreate
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.dialog_colorpicker);
RecyclerView recycler = ((RecyclerView) findViewById(R.id.colorful_color_picker_recycler));
Toolbar toolbar = ((Toolbar) findViewById(R.id.colorful_color_picker_toolbar));
toolbar.setNavigationOnClickListener(this);
toolbar.setBackgroundColor(getContext().getResources().getColor(Colorful.getThemeDelegate().getPrimaryColor().getColorRes()));
toolbar.setTitle(R.string.select_color);
toolbar.setNavigationIcon(R.drawable.ic_arrow_back);
recycler.setLayoutManager(new GridLayoutManager(getContext(), 4));
ColorPickerAdapter adapter = new ColorPickerAdapter(getContext());
adapter.setOnItemClickListener(this);
recycler.setAdapter(adapter);
}
示例10: onCreate
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.settings_tutorial_activity);
Toolbar toolbar = (Toolbar) findViewById(R.id.settings_toolbar);
toolbar.setTitle(R.string.settings_tutorial);
toolbar.setNavigationIcon(R.drawable.ic_arrow_back_white_24dp);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onBackPressed();
}
});
}
示例11: setUpToolbar
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
private void setUpToolbar() {
mToolbar = (Toolbar) findViewById(R.id.activity_place_toolbar);
mToolbar.setTitle(getResources().getString( (mPlaceToEdit != null ? R.string.activity_place_title_edit : R.string.activity_place_title_new) ));
mToolbar.setNavigationIcon(ContextCompat.getDrawable(this, R.drawable.icon_back_material));
//Set toolbar as actionbar
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
}
示例12: setupToolbar
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
protected void setupToolbar(Toolbar mToolbar, boolean homeIconVisible) {
if (mToolbar == null) {
throw new RuntimeException("toolbar cannot be null!");
}
if (null == getSupportActionBar()) {
setSupportActionBar(mToolbar);
}
getSupportActionBar().setDisplayHomeAsUpEnabled(homeIconVisible);
getSupportActionBar().setDisplayShowTitleEnabled(false);
mToolbar.setNavigationIcon(R.drawable.fanhui);
}
示例13: initToolbar
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
public void initToolbar(Toolbar toolbar, String title, int menuRes) {
if (toolbar != null) {
toolbar.setTitle(title);
toolbar.setNavigationIcon(R.drawable.ic_menu);
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
openOrCloseDrawer(true);
}
});
toolbar.inflateMenu(menuRes);
}
}
示例14: onCreate
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_about);
toolbar = (Toolbar) findViewById(R.id.toolbar);
toolbar.setNavigationIcon(ContextCompat.getDrawable(this, R.drawable.action_home));
toolbar.setNavigationOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
finish();
}
});
toolbar.setTitle(R.string.action_about);
}
示例15: setUpToolbar
import android.support.v7.widget.Toolbar; //导入方法依赖的package包/类
private void setUpToolbar() {
mToolbar = (Toolbar) findViewById(R.id.activity_settings_toolbar);
mToolbar.setTitle(getResources().getString(R.string.activity_settings_toolbar_title));
mToolbar.setNavigationIcon(ContextCompat.getDrawable(this, R.drawable.icon_back_material));
//Set toolbar as actionbar
setSupportActionBar(mToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
}