2015-10-30 109 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> 

我想我应该在里面添加的东西。但我不清楚。

我在做什么错误,我该如何解决这个问题?

回答