2015-10-30 108 views
0

我從Android Studio中Android的顯示佈局從抽屜式導航欄上的「onNavigationItemSelected」

從抽屜式導航在左側創建一個空的項目,我編輯這樣

<group android:checkableBehavior="single"> 
    <item android:id="@+id/nav_blog" 
     android:title="Blog" /> 
    <item android:id="@+id/nav_task" 
     android:title="Task" /> 
</group> 

控件雖然我點擊在nav_blog

我有這樣的活動

if (id == R.id.nav_blog) { 
     setContentView(R.layout.layout_blog); 
    } else if (id == R.id.nav_task) { 
setContentView(R.layout.layout_task); 
    } 

裏面的RES /佈局

我有nav_task.xml和layout_task.xml

但是,當我點擊抽屜式導航欄總是我的應用程序崩潰的仿真器和顯示此日誌

邊欄上

我在做什麼錯誤..

我怎樣才能顯示佈局,當我點擊導航抽屜上的項目。

10-30 15:28:29.010 945-945/? E/libEGL: called unimplemented OpenGL ES API 
10-30 15:28:29.010 945-945/? E/SurfaceFlinger: glCheckFramebufferStatusOES error 1907239303 
10-30 15:28:29.010 945-945/? E/SurfaceFlinger: got GL_FRAMEBUFFER_COMPLETE_OES error while taking screenshot 
10-30 15:28:30.610 1307-1465/? W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client 
10-30 15:28:32.170 1307-1561/? I/ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10000000 cmp=com.example.sulthan.sa/.SysMain (has extras)} from uid 10007 on display 0 
10-30 15:28:34.120 1307-1465/? W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client 
10-30 15:28:35.210 1307-1465/? W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client 
10-30 15:28:37.290 1307-1465/? W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client 
10-30 15:28:38.460 1307-1465/? W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client 
10-30 15:28:40.320 1307-1465/? W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client 
10-30 15:28:41.050 1307-1465/? W/AudioTrack: AUDIO_OUTPUT_FLAG_FAST denied by client 
10-30 15:34:00.810 1307-1334/? W/BatteryStatsImpl: Couldn't get kernel wake lock stats 
10-30 15:35:11.810 1307-1307/? I/EntropyMixer: Writing entropy... 
10-30 15:37:00.020 1307-1328/? I/ProcessStatsService: Prepared write state in 0ms 
10-30 15:38:16.770 3761-3761/? D/AndroidRuntime: CheckJNI is ON 
10-30 15:38:16.790 3761-3761/? E/memtrack: Couldn't load memtrack module (No such file or directory) 
10-30 15:38:16.790 3761-3761/? E/android.os.Debug: failed to load memtrack module: -2 
10-30 15:38:16.810 2278-2293/? D/DefContainer: Copying /data/local/tmp/com.example.sulthan.sa to base.apk 
10-30 15:38:16.880 1307-1338/? D/PackageManager: Renaming /data/app/vmdl1512606718.tmp to /data/app/com.example.sulthan.sa-2 
10-30 15:38:16.890 1307-1328/? W/ActivityManager: Force removing ActivityRecord{1d72e8d0 u0 com.example.sulthan.sa/.SysMain t37}: app died, no saved state 
10-30 15:38:16.960 3772-3772/? E/cutils-trace: Error opening trace file: Permission denied (13) 
10-30 15:38:16.960 3772-3772/? I/dex2oat: /system/bin/dex2oat --zip-fd=5 --zip-location=/data/app/com.example.sulthan.sa-2/base.apk --oat-fd=6 --oat-location=/data/dalvik-cache/x86_64/[email protected]@[email protected]@classes.dex --instruction-set=x86_64 --instruction-set-features=default --runtime-arg -Xms64m --runtime-arg -Xmx512m 
10-30 15:38:17.390 3772-3772/? W/dex2oat: Before Android 4.1, method int android.support.v7.internal.widget.ListViewCompat.lookForSelectablePosition(int, boolean) would have incorrectly overridden the package-private method in android.widget.ListView 
10-30 15:38:18.920 3772-3772/? I/dex2oat: dex2oat took 1.960s (threads: 1) 

在主要活動

更新:

這裏是AndroidManifest.xml中

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.sulthan.sa" > 

    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme" > 
     <activity 
      android:name=".SysMain" 
      android:label="@string/app_name" 
      android:theme="@style/AppTheme.NoActionBar" > 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 
       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
    </application> 
</manifest> 

我想我應該在裏面添加的東西。但我不清楚。

我在做什麼錯誤,我該如何解決這個問題?

回答