本文整理了Java中android.support.design.widget.NavigationView.getHeaderView()
方法的一些代码示例,展示了NavigationView.getHeaderView()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。NavigationView.getHeaderView()
方法的具体详情如下:
包路径:android.support.design.widget.NavigationView
类名称:NavigationView
方法名:getHeaderView
暂无
代码示例来源:origin: north2016/T-MVP
@Override
public void initUserInfo(User user) {
View mHeaderView = mViewBinding.nvMainNavigation.getHeaderView(0);
ImageView im_face = (ImageView) mHeaderView.findViewById(R.id.im_face);
TextView tv_name = (TextView) mHeaderView.findViewById(R.id.tv_name);
BindingUtils.loadRoundImg(im_face, user.face);
tv_name.setText(user.username);
}
代码示例来源:origin: TeamNewPipe/NewPipe
private void setupDrawerHeader() {
NavigationView navigationView = findViewById(R.id.navigation);
View hView = navigationView.getHeaderView(0);
serviceArrow = hView.findViewById(R.id.drawer_arrow);
headerServiceView = hView.findViewById(R.id.drawer_header_service_view);
Button action = hView.findViewById(R.id.drawer_header_action_button);
action.setOnClickListener(view -> {
toggleServices();
});
}
代码示例来源:origin: MindorksOpenSource/android-mvp-architecture
void setupNavMenu() {
View headerLayout = mNavigationView.getHeaderView(0);
mProfileImageView = (RoundedImageView) headerLayout.findViewById(R.id.iv_profile_pic);
mNameTextView = (TextView) headerLayout.findViewById(R.id.tv_name);
mEmailTextView = (TextView) headerLayout.findViewById(R.id.tv_email);
mNavigationView.setNavigationItemSelectedListener(
new NavigationView.OnNavigationItemSelectedListener() {
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
mDrawer.closeDrawer(GravityCompat.START);
switch (item.getItemId()) {
case R.id.nav_item_about:
mPresenter.onDrawerOptionAboutClick();
return true;
case R.id.nav_item_rate_us:
mPresenter.onDrawerRateUsClick();
return true;
case R.id.nav_item_feed:
mPresenter.onDrawerMyFeedClick();
return true;
case R.id.nav_item_logout:
mPresenter.onDrawerOptionLogoutClick();
return true;
default:
return false;
}
}
});
}
代码示例来源:origin: pockethub/PocketHub
private void setUpHeaderView() {
ImageView userImage;
TextView userRealName;
TextView userName;
View headerView = navigationView.getHeaderView(0);
userImage = headerView.findViewById(R.id.user_picture);
ImageView notificationIcon = headerView.findViewById(R.id.iv_notification);
userRealName = headerView.findViewById(R.id.user_real_name);
userName = headerView.findViewById(R.id.user_name);
notificationIcon.setOnClickListener(v ->
startActivity(new Intent(MainActivity.this, NotificationActivity.class)));
avatars.bind(userImage, org);
userName.setText(org.login());
String name = org.name();
if (name != null) {
userRealName.setText(org.name());
} else {
userRealName.setVisibility(View.GONE);
}
}
代码示例来源:origin: xinghongfei/LookLook
@Override
public void getPic() {
View headerLayout = navView.getHeaderView(0);
LinearLayout llImage = (LinearLayout) headerLayout.findViewById(R.id.side_image);
if (new File(getFilesDir().getPath() + "/bg.jpg").exists()) {
BitmapDrawable bitmapDrawable = new BitmapDrawable(getResources(), getFilesDir().getPath() + "/bg.jpg");
llImage.setBackground(bitmapDrawable);
}
}
代码示例来源:origin: HotBitmapGG/bilibili-android-client
/**
* 初始化NavigationView
*/
private void initNavigationView() {
mNavigationView.setNavigationItemSelectedListener(this);
View headerView = mNavigationView.getHeaderView(0);
CircleImageView mUserAvatarView = (CircleImageView) headerView.findViewById(R.id.user_avatar_view);
TextView mUserName = (TextView) headerView.findViewById(R.id.user_name);
TextView mUserSign = (TextView) headerView.findViewById(R.id.user_other_info);
ImageView mSwitchMode = (ImageView) headerView.findViewById(R.id.iv_head_switch_mode);
//设置头像
mUserAvatarView.setImageResource(R.drawable.ic_hotbitmapgg_avatar);
//设置用户名 签名
mUserName.setText(getResources().getText(R.string.hotbitmapgg));
mUserSign.setText(getResources().getText(R.string.about_user_head_layout));
//设置日夜间模式切换
mSwitchMode.setOnClickListener(v -> switchNightMode());
boolean flag = PreferenceUtil.getBoolean(ConstantUtil.SWITCH_MODE_KEY, false);
if (flag) {
mSwitchMode.setImageResource(R.drawable.ic_switch_daily);
} else {
mSwitchMode.setImageResource(R.drawable.ic_switch_night);
}
}
代码示例来源:origin: frogermcs/InstaMaterial
private void setupHeader() {
View headerView = vNavigation.getHeaderView(0);
ivMenuUserProfilePhoto = (ImageView) headerView.findViewById(R.id.ivMenuUserProfilePhoto);
headerView.findViewById(R.id.vGlobalMenuHeader).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
onGlobalMenuHeaderClick(v);
}
});
Picasso.with(this)
.load(profilePhoto)
.placeholder(R.drawable.img_circle_placeholder)
.resize(avatarSize, avatarSize)
.centerCrop()
.transform(new CircleTransformation())
.into(ivMenuUserProfilePhoto);
}
代码示例来源:origin: seven332/EhViewer
mNavView = (NavigationView) ViewUtils.$$(this, R.id.nav_view);
mRightDrawer = (FrameLayout) ViewUtils.$$(this, R.id.right_drawer);
View headerLayout = mNavView.getHeaderView(0);
mAvatar = (LoadImageView) ViewUtils.$$(headerLayout, R.id.avatar);
mDisplayName = (TextView) ViewUtils.$$(headerLayout, R.id.display_name);
代码示例来源:origin: mayubao/KuaiChuan
tv_name = (TextView) mNavigationView.getHeaderView(0).findViewById(R.id.tv_name);
tv_name.setText(device);
}catch(Exception e){
代码示例来源:origin: GcsSloop/diycode
private void loadMenuData() {
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
View headerView = navigationView.getHeaderView(0);
ImageView avatar = (ImageView) headerView.findViewById(R.id.nav_header_image);
TextView username = (TextView) headerView.findViewById(R.id.nav_header_name);
代码示例来源:origin: eneim/toro
navView.getHeaderView(3).<TextView>findViewById(R.id.text_content).setText(
Html.fromHtml(getString(R.string.lib_info_license)));
代码示例来源:origin: fossasia/pslab-android
mHandler = new Handler();
navHeader = navigationView.getHeaderView(0);
txtName = navHeader.findViewById(io.pslab.R.id.name);
imgProfile = navHeader.findViewById(io.pslab.R.id.img_profile);
代码示例来源:origin: livroandroid/5ed
public static void setNavViewValues(NavigationView navView, int nome, int email, int img) {
View headerView = navView.getHeaderView(0);
TextView tNome = (TextView) headerView.findViewById(R.id.tNome);
TextView tEmail = (TextView) headerView.findViewById(R.id.tEmail);
ImageView imgView = (ImageView) headerView.findViewById(R.id.img);
tNome.setText(nome);
tEmail.setText(email);
imgView.setImageResource(img);
}
代码示例来源:origin: CoderGuoy/Coder
/**
* 初始化侧拉菜单
*/
private void initDrawerlayout() {
View headerView = bindingView.navigationview.getHeaderView(0);
NavigationHeaderBinding bind = DataBindingUtil.bind(headerView);
bind.llNavVideo.setOnClickListener(listener);
bind.llNav2.setOnClickListener(listener);
bind.llNav3.setOnClickListener(listener);
bind.llNav4.setOnClickListener(listener);
bind.llNav5.setOnClickListener(listener);
}
代码示例来源:origin: LRH1993/LiveCircle
/**
* 设置导航页信息
*/
private void setNavigationView() {
//NavigationView初始化
mAmNv.setItemIconTintList(null);
View headerView = mAmNv.getHeaderView(0);
mIv_photo = (ImageView) headerView.findViewById(R.id.iv_user_photo);
}
代码示例来源:origin: thuryn/your-local-weather
private void configureNavView() {
NavigationView navigationView = (NavigationView) findViewById(R.id.navigation_view);
navigationView.setNavigationItemSelectedListener(navigationViewListener);
View headerLayout = navigationView.getHeaderView(0);
mHeaderCity = (TextView) headerLayout.findViewById(R.id.nav_header_city);
//mHeaderCity.setText(Utils.getCityAndCountry(this));
}
代码示例来源:origin: WhiteDG/BihuDaily
private void initDrawerLayout() {
mDrawerLayout.setStatusBarBackground(R.color.colorPrimaryDark);
// assert navView != null;
setupDrawerContent(navView);
View view = navView.getHeaderView(0);
// assert llDrawer != null;
// setupDrawerContent(llDrawer);
tvMyStar = (TextView) view.findViewById(R.id.tv_my_star);
tvOfflineDownload = (TextView) view.findViewById(R.id.tv_offline_download);
llNavUser = (LinearLayout) view.findViewById(R.id.ll_nav_user);
}
代码示例来源:origin: qqq3/good-weather
private void configureNavView() {
NavigationView navigationView = (NavigationView) findViewById(R.id.navigation_view);
navigationView.setNavigationItemSelectedListener(navigationViewListener);
View headerLayout = navigationView.getHeaderView(0);
mHeaderCity = (TextView) headerLayout.findViewById(R.id.nav_header_city);
mHeaderCity.setText(Utils.getCityAndCountry(this));
}
代码示例来源:origin: WangDaYeeeeee/Mysplash
@Override
public void touchMeAvatar(MysplashActivity a) {
NavigationView nav = a.findViewById(R.id.activity_main_navView);
View header = nav.getHeaderView(0);
IntentHelper.startMeActivity(
a,
header.findViewById(R.id.container_nav_header_avatar),
header.findViewById(R.id.container_nav_header),
UserActivity.PAGE_PHOTO);
}
代码示例来源:origin: daquexian/chaoli-forum-for-android-2
@Override
public void setViewModel(BaseViewModel viewModel) {
this.viewModel = (MainActivityVM) viewModel;
binding = DataBindingUtil.setContentView(this, R.layout.main_activity);
binding.setViewModel(this.viewModel);
NavigationHeaderBinding navigationHeaderBinding = NavigationHeaderBinding.bind(binding.navigationView.getHeaderView(0));
navigationHeaderBinding.setViewModel(this.viewModel);
}
}
内容来源于网络,如有侵权,请联系作者删除!