2017-06-16 13 views
-3

私はアンドロイドスタジオでアプリを実行しようとしましたが、私はこの奇妙なエラーが発生し続けます。ナビゲーション引き出しのエラー

このエラーの内容と解決方法はほとんど分かりませんでした。ここで

ここでlogcat

06-16 15:26:02.141 5270-5270/com.sensiblewallet E/AndroidRuntime: FATAL EXCEPTION: main 
Process: com.sensiblewallet, PID: 5270 
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sensiblewallet/com.sensiblewallet.ActivityMainWallet}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2452) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512) 
    at android.app.ActivityThread.-wrap11(ActivityThread.java) 
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376) 
    at android.os.Handler.dispatchMessage(Handler.java:102) 
    at android.os.Looper.loop(Looper.java:148) 
    at android.app.ActivityThread.main(ActivityThread.java:5481) 
    at java.lang.reflect.Method.invoke(Native Method) 
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728) 
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618) 
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference 
    at com.sensiblewallet.ActivityMainWallet.onCreate(ActivityMainWallet.java:212) 
    at android.app.Activity.performCreate(Activity.java:6251) 
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) 
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2405) 
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)  
    at android.app.ActivityThread.-wrap11(ActivityThread.java)  
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1376)  
    at android.os.Handler.dispatchMessage(Handler.java:102)  
    at android.os.Looper.loop(Looper.java:148)  
    at android.app.ActivityThread.main(ActivityThread.java:5481)  
    at java.lang.reflect.Method.invoke(Native Method)  
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:728)  
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)  

でそれが指示されているコードの一部です。

mDrawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout); 
mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.END); 
mDrawerLay = (NavigationView)findViewById(R.id.navigation_view); 
mDrawerLay.setNavigationItemSelectedListener(this); 
TextView navigationTotalCreditTextView = (TextView)mDrawerLay.findViewById(R.id.nav_drawer_total_credits); 
navigationTotalCreditTextView.setText("Total Credits: " + PreferenceConnector.readInteger(aiContext, 
     PreferenceConnector.WALLETPOINTS, 0)); 
TextView navigationWalletIDText = (TextView)mDrawerLay.findViewById(R.id.nav_drawer_wallet_id); 
navigationWalletIDText.setText("Wallet ID: " + PreferenceConnector.readString(aiContext, 
     PreferenceConnector.WALLETID, "")); 
TextView navigationUsernameText = (TextView)mDrawerLay.findViewById(R.id.nav_drawer_username); 
navigationUsernameText.setText(PreferenceConnector.readString(aiContext, 
     PreferenceConnector.USERNAME, "")); 
// MyUtils.setFontAllView((RelativeLayout)findViewById(R.id.laymenu)); 
+0

このリンクを参照してください:http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/は非常にGUDアンドロイドナビゲーションドロワーのリファレンス... –

答えて

0

このコードを試してみてください。

View v = mDrawerLay.getHeaderView(0); 
    TextView navigationTotalCreditTextView = (TextView)v.findViewById(R.id.nav_drawer_total_credits); 
    TextView navigationWalletIDText = (TextView)v.findViewById(R.id.nav_drawer_wallet_id); 
navigationWalletIDText.setText("Wallet ID: " + PreferenceConnector.readString(aiContext, 
     PreferenceConnector.WALLETID, "")); 
    TextView navigationUsernameText = (TextView)v .findViewById(R.id.nav_drawer_username); 
navigationUsernameText.setText(PreferenceConnector.readString(aiContext, 
     PreferenceConnector.USERNAME, "")); 
関連する問題