當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。