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


Java NavigationView.inflateHeaderView方法代码示例

本文整理汇总了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的时候会重新检查
    }
 
开发者ID:GrayXu,项目名称:HustEating,代码行数:37,代码来源:MainActivity.java

示例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());
}
 
开发者ID:ayounes3333,项目名称:GSB-2017-Android,代码行数:36,代码来源:MainActivity.java

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

}
 
开发者ID:Vinetos,项目名称:Hello-Music-droid,代码行数:70,代码来源:MainActivity.java

示例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());
}
 
开发者ID:li-yu,项目名称:FakeWeather,代码行数:6,代码来源:MainActivity.java


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