本文整理汇总了Java中android.support.design.widget.NavigationView.inflateHeaderView方法的典型用法代码示例。如果您正苦于以下问题:Java NavigationView.inflateHeaderView方法的具体用法?Java NavigationView.inflateHeaderView怎么用?Java NavigationView.inflateHeaderView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.support.design.widget.NavigationView
的用法示例。
在下文中一共展示了NavigationView.inflateHeaderView方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initDrawer
import android.support.design.widget.NavigationView; //导入方法依赖的package包/类
/**
* 初始化抽屉布局
*/
private void initDrawer() {
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
// SharedPreferences preferences = getPreferences(MODE_PRIVATE);
//初始化的时候载入toolBar的颜色
String tasteChosen = getSharedPreferences("MainActivity", MODE_PRIVATE).getString("tasteChosen", "辣");
String color = "0";
if (tasteChosen.equals("辣")) {
color = "#FF0000";
} else if (tasteChosen.equals("清淡")) {
color = "#BFEFFF";
} else if (tasteChosen.equals("香")) {
color = "#EEC900";
} else if (tasteChosen.equals("甜")) {
color = "#FFAEB9";
}
toolbar.setBackgroundColor(Color.parseColor(color));
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
navigationView.setNavigationItemSelectedListener(this);
navigationView.inflateHeaderView(R.layout.main_nav_header_nologin);//预加载一个未登录的界面,在onResume的时候会重新检查
}
示例2: onCreate
import android.support.design.widget.NavigationView; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
fab = (FloatingActionButton) findViewById(R.id.fab);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.frameLayout_fragment_container,
new ClientsFragment(),
ClientsFragment.TAG)
.commit();
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
startActivity(new Intent(MainActivity.this , AjouteClientActivity.class));
}
});
if(getSupportActionBar() != null)
getSupportActionBar().setTitle(R.string.clients);
DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(
this, drawer, toolbar, R.string.navigation_drawer_open, R.string.navigation_drawer_close);
drawer.addDrawerListener(toggle);
toggle.syncState();
NavigationView navigationView = (NavigationView) findViewById(R.id.nav_view);
View headerView = navigationView.inflateHeaderView(R.layout.nav_header_main);
navigationView.setNavigationItemSelectedListener(this);
((TextView) headerView.findViewById(R.id.textView_fullName)).setText(PrefUtils.getUsername());
((TextView) headerView.findViewById(R.id.textView_emailUsername)).setText(PrefUtils.getUserEmail());
}
示例3: onCreate
import android.support.design.widget.NavigationView; //导入方法依赖的package包/类
@Override
public void onCreate(Bundle savedInstanceState) {
sMainActivity = this;
action = getIntent().getAction();
isDarkTheme = PreferenceManager.getDefaultSharedPreferences(this).getBoolean("dark_theme", false);
super.onCreate(savedInstanceState);
// Checking for updates
PreferencesManager prefManager = new PreferencesManager(this);
if (prefManager.canCheckUpdate(sMainActivity)) {
prefManager.updateLastUpdateTime();
startActivity(new Intent(this, UpdaterActivity.class));
}
setContentView(R.layout.activity_main);
navigationMap.put(Constants.NAVIGATE_LIBRARY, navigateLibrary);
navigationMap.put(Constants.NAVIGATE_PLAYLIST, navigatePlaylist);
navigationMap.put(Constants.NAVIGATE_QUEUE, navigateQueue);
navigationMap.put(Constants.NAVIGATE_NOWPLAYING, navigateNowplaying);
navigationMap.put(Constants.NAVIGATE_ALBUM, navigateAlbum);
navigationMap.put(Constants.NAVIGATE_ARTIST, navigateArtist);
mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
panelLayout = (SlidingUpPanelLayout) findViewById(R.id.sliding_layout);
navigationView = (NavigationView) findViewById(R.id.nav_view);
View header = navigationView.inflateHeaderView(R.layout.nav_header);
albumart = (ImageView) header.findViewById(R.id.album_art);
songtitle = (TextView) header.findViewById(R.id.song_title);
songartist = (TextView) header.findViewById(R.id.song_artist);
setPanelSlideListeners(panelLayout);
navDrawerRunnable.postDelayed(new Runnable() {
@Override
public void run() {
setupDrawerContent(navigationView);
setupNavigationIcons(navigationView);
}
}, 700);
if (TimberUtils.isMarshmallow()) {
checkPermissionAndThenLoad();
} else {
loadEverything();
}
addBackstackListener();
if (Intent.ACTION_VIEW.equals(action)) {
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
MusicPlayer.clearQueue();
MusicPlayer.openFile(getIntent().getData().getPath());
MusicPlayer.playOrPause();
navigateNowplaying.run();
}
}, 350);
}
}
示例4: initNavigationViewHeader
import android.support.design.widget.NavigationView; //导入方法依赖的package包/类
private void initNavigationViewHeader() {
navigationView = (NavigationView) findViewById(R.id.navigation);
navigationView.inflateHeaderView(R.layout.drawer_header);
navigationView.setNavigationItemSelectedListener(new NavigationItemSelected());
}