最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Android studio有關(guān)側(cè)滑的實(shí)現(xiàn)代碼

 更新時(shí)間:2020年06月04日 09:53:15   作者:努力學(xué)習(xí)中.....  
這篇文章主要介紹了Android studio有關(guān)側(cè)滑的實(shí)現(xiàn)代碼,本文給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下

最近寫課設(shè),因?yàn)槭切率郑瑢?shí)現(xiàn)起來比較麻煩。所以寫下此筆記,免得我以后忘記了。

附圖片:

在這里插入圖片描述

//主頁面的布局
activity_main.xml:

<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  xmlns:qpp="http://schemas.android.com/apk/res-auto"
  android:id="@+id/drawer_layout"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:fitsSystemWindows="true"
  tools:openDrawer="start">
  <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Hello World!"
     />

  <android.support.design.widget.NavigationView
    android:id="@+id/nav_view"
    android:layout_width="207dp"
    android:layout_height="match_parent"
    android:layout_gravity="left"
    android:fitsSystemWindows="true"
    qpp:headerLayout="@layout/stumenu1"
    qpp:menu="@menu/stumenu1" />

</android.support.v4.widget.DrawerLayout>

頭部的布局(放入layout)
stumenu1.xml:

<?xml version="1.0" encoding="utf-8"?>
<!--學(xué)生左滑后界面-->
<android.support.constraint.ConstraintLayout
  xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:layout_width="match_parent"
  android:layout_height="match_parent">

  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    >

    <ImageView
      android:id="@+id/person"
      android:layout_width="72dp"
      android:layout_height="72dp"
      android:layout_marginTop="75dp"
      android:src="@drawable/student"
      />
    <TextView
      android:id="@+id/stutv"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:textSize="20sp"
      android:layout_marginTop="20dp"
      android:textColor="#282525"
      android:text="測試APP"/>

  </LinearLayout>

</android.support.constraint.ConstraintLayout>

菜單的布局:(放在menu文件夾)
stumenu1

<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:app="http://schemas.android.com/apk/res-auto">
  <group
    android:checkableBehavior="single">
    <item
      android:id="@+id/result"
      android:icon="@drawable/ic_launcher_background"
      android:checkable="true"
      android:title=" 測試結(jié)果"/>

  <item
    android:id="@+id/w1"
    android:icon="@drawable/ic_launcher_background"

    android:title=" 錯(cuò)題"/>
  <item
    android:id="@+id/s1"
    android:icon="@drawable/ic_launcher_background"
    android:title=" 得分"/>

  <item
    android:id="@+id/exit"
    android:icon="@drawable/ic_launcher_background"
    android:title=" 退出"/>
  </group>
</menu>

MainActivity.java:

package com.example.cholewu.slide;

import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.design.widget.NavigationView;
import android.support.v4.widget.DrawerLayout;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.Toast;

public class MainActivity extends AppCompatActivity {

  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    //左滑菜單
    initView();
  }
  private void initView() {

    //實(shí)現(xiàn)左右滑動(dòng)
    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    //菜單控件
    final NavigationView nv = findViewById(R.id.nav_view);
    nv.setItemIconTintList(null);
    
    nv.setNavigationItemSelectedListener(new NavigationView.OnNavigationItemSelectedListener() {
      @Override
      public boolean onNavigationItemSelected(@NonNull MenuItem item) {

        switch (item.getItemId()){
          case R.id.exit:
            //跳轉(zhuǎn)到退出頁面
            Toast.makeText(MainActivity.this,"你已退出登錄!",Toast.LENGTH_SHORT).show();
            Intent intent=new Intent();
            intent.setClass(MainActivity.this,Exit.class);
            startActivity(intent);
            item.setChecked(true);
            break;
        }

        item.setCheckable(true);//設(shè)置可選項(xiàng)
        item.setChecked(true);//設(shè)置被選中
        drawer.closeDrawers();//關(guān)閉菜單欄
        return true;
      }

    });
  }
}

(注意:如果直接復(fù)制代碼的話,android.support.design.widget.NavigationView可能會(huì)出錯(cuò),需要自己在design那里布局,如果出錯(cuò),可以看看以下NavigationView右邊是否有下載圖案,點(diǎn)擊下載就行了)

在這里插入圖片描述

總結(jié)

到此這篇關(guān)于Android studio有關(guān)側(cè)滑的實(shí)現(xiàn)的文章就介紹到這了,更多相關(guān)Android studio有關(guān)側(cè)滑的實(shí)現(xiàn)內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

  • 實(shí)例講解Android Fragment的兩種使用方法

    實(shí)例講解Android Fragment的兩種使用方法

    今天小編就為大家分享一篇關(guān)于實(shí)例講解Android Fragment的兩種使用方法,小編覺得內(nèi)容挺不錯(cuò)的,現(xiàn)在分享給大家,具有很好的參考價(jià)值,需要的朋友一起跟隨小編來看看吧
    2019-03-03
  • 優(yōu)化SimpleAdapter適配器加載效率的方法

    優(yōu)化SimpleAdapter適配器加載效率的方法

    下面小編就為大家?guī)硪黄獌?yōu)化SimpleAdapter適配器加載效率的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧
    2017-04-04
  • AndroidStudio4.0 New Class的坑(小結(jié))

    AndroidStudio4.0 New Class的坑(小結(jié))

    這篇文章主要介紹了AndroidStudio4.0 New Class的坑,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2020-07-07
  • Android組件創(chuàng)建DrawerLayout導(dǎo)航

    Android組件創(chuàng)建DrawerLayout導(dǎo)航

    這篇文章主要為大家詳細(xì)介紹了Android組件創(chuàng)建DrawerLayout導(dǎo)航的相關(guān)資料,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2017-01-01
  • Kotlin開發(fā)中與if等價(jià)的takeIf與takeUnless詳解

    Kotlin開發(fā)中與if等價(jià)的takeIf與takeUnless詳解

    這篇文章主要介紹了Kotlin開發(fā)中與if等價(jià)的takeIf與takeUnless使用,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧
    2023-01-01
  • 大型項(xiàng)目里Flutter測試應(yīng)用實(shí)例集成測試深度使用詳解

    大型項(xiàng)目里Flutter測試應(yīng)用實(shí)例集成測試深度使用詳解

    這篇文章主要為大家介紹了大型項(xiàng)目里Flutter測試應(yīng)用實(shí)例集成測試深度使用詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2022-12-12
  • android 之Spinner下拉菜單實(shí)現(xiàn)級聯(lián)

    android 之Spinner下拉菜單實(shí)現(xiàn)級聯(lián)

    android 之Spinner下拉菜單實(shí)現(xiàn)級聯(lián),需要的朋友可以參考一下
    2013-02-02
  • Android WebView 應(yīng)用界面開發(fā)教程

    Android WebView 應(yīng)用界面開發(fā)教程

    WebView組件本身就是一個(gè)瀏覽器實(shí)現(xiàn),開發(fā)者可以直接在WebView中使用聚合(Polymer)和Material設(shè)計(jì)。接下來通過本文給大家介紹Android WebView 應(yīng)用界面開發(fā)教程,一起看下吧
    2016-08-08
  • Android實(shí)現(xiàn)文字動(dòng)態(tài)高亮讀取進(jìn)度效果

    Android實(shí)現(xiàn)文字動(dòng)態(tài)高亮讀取進(jìn)度效果

    這篇文章主要為大家詳細(xì)介紹了Android實(shí)現(xiàn)文字動(dòng)態(tài)高亮讀取進(jìn)度效果,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2021-05-05
  • Android?Gradle?插件自定義Plugin實(shí)現(xiàn)注意事項(xiàng)

    Android?Gradle?插件自定義Plugin實(shí)現(xiàn)注意事項(xiàng)

    這篇文章主要介紹了Android?Gradle?插件自定義Plugin實(shí)現(xiàn)注意事項(xiàng),文章圍繞主題展開詳細(xì)的內(nèi)容介紹,具有一定的參考價(jià)值,需要的朋友可以參考一下
    2022-06-06

最新評論

象山县| 林甸县| 准格尔旗| 佛坪县| 平凉市| 芒康县| 铜陵市| 广南县| 白玉县| 信宜市| 盈江县| 宜黄县| 浦北县| 左贡县| 桐城市| 汾阳市| 麦盖提县| 广灵县| 台江县| 惠州市| 齐齐哈尔市| 临清市| 永和县| 长白| 英超| 顺昌县| 杭锦后旗| 集贤县| 宁陵县| 大足县| 彭山县| 通江县| 公安县| 扬中市| 梅河口市| 齐河县| 临泉县| 潜山县| 时尚| 保山市| 民权县|