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


Java Toolbar.setNavigationIcon方法代码示例

本文整理汇总了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));
                }
            }
        }
    }
 
开发者ID:rudsonlive,项目名称:liveomvp,代码行数:17,代码来源:BaseActivity.java

示例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);
}
 
开发者ID:tony-Shx,项目名称:Swface,代码行数:24,代码来源:ManageActivity.java

示例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();
        }
    });
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:24,代码来源:PersonalHomeActivity.java

示例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));
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:MusicActivity.java

示例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));

}
 
开发者ID:paradoxie,项目名称:DizzyPassword,代码行数:20,代码来源:TeachActivity.java

示例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();
        }
    });
}
 
开发者ID:funnyzhaov,项目名称:Tribe,代码行数:28,代码来源:PersonalHomeActivity.java

示例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();
            }
        });
    }
}
 
开发者ID:newDeepLearing,项目名称:decoy,代码行数:25,代码来源:UI.java

示例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();

}
 
开发者ID:rishabh115,项目名称:Odyssey2017,代码行数:24,代码来源:EventActivity.java

示例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);
}
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:19,代码来源:ColorPickerDialog.java

示例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();
        }
    });

}
 
开发者ID:Team-Sprout,项目名称:Clipcon-AndroidClient,代码行数:17,代码来源:SettingsTutorialActivity.java

示例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);
}
 
开发者ID:abicelis,项目名称:Remindy,代码行数:11,代码来源:PlaceActivity.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:BaseActivity.java

示例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);
    }
}
 
开发者ID:SirLYC,项目名称:Android-Gank-Share,代码行数:14,代码来源:MainActivity.java

示例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);
}
 
开发者ID:sega4revenge,项目名称:Sega,代码行数:15,代码来源:AboutActivity.java

示例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);

    }
 
开发者ID:abicelis,项目名称:Remindy,代码行数:13,代码来源:SettingsActivity.java


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