Monday 15 March 2010

xml - Android - change font of navigation drawer/text -


I am implementing a navigation drawer in my app and I want to change the font. Below is my cleaning method where I change the font of the navigation drawer, the problem occurs when this app runs, it crashes instantly and I do not know what is wrong

code:

  Create a public null (bundle saved instenestate) {super. Contents (Saved Instantstate); SetContentView (R.layout.navdrawer); Android.support.v4.app.FragmentManager Slice Manager = getSupportFragmentManager (); Android.support.v4.app.FragmentTransaction fragmentTransaction = fragmentManager .beginTransaction (); Home piece = new home (); Piece transaction. Riley (RID. Löhme, piece); FragmentTransaction.commit (); Typeface TF = Typeface (getAssets (), "Robotomed.TTF"); TextView TV = (TextView) findViewById (R.id.tvmenu); Tv.setTypeface (tf); MPlanetTitles = getResources (). GetStringArray (R.RA.Planets_Are); MDrawerList = (list view) Find VVBID (RID. Left_driver); MDrawerList.setAdapter (New Array Adapter & lt; String & gt; (This, R. Late. Drawer_List_List_List_Litem, Emplanet Title)); // List Listener Mdrr List. Set-On Item ClickClicklist (New DruiterInstall ClickClicklist); MDrawerLayout = (DrawerLayout) findViewById (R.id.drawer_layout); mDrawerToggle = new ActionBarDrawerToggle (This, / * host activity * / MDrawerLayout, / * DrawerLayout object * / Rkdrawablekic_drawer, / * 'up' caret * / Rkstringkdrawer_open, / * "Neo drawer to replace open Drawer "Description * / R. String Drawer_clos / *" Close Dover "description * /) {/ ** When a drawer is fully settled in the closed state. * / Public Zero on Drawerclosed (see View) {getActionBar () SetTitle ("Home"); } / ** is called when a drawer is fully settled in the open space. * / Public Nero on the Drewer Open (see View Drawerview) {getActionBar () SetTitle ("StayHealthy"); }}; // drawer trigger, drawer listener, MDR out Set as SetDriverListener (MDRRware); GetActionBar () setDisplayHomeAsUpEnabled (true). GetActionBar () setHomeButtonEnabled (true) }   

This is my logcat

  06-22 21: 44: 21.562: E / Android Random (32042): Fatal Exceptions: Key 06-22 21: 44: 21.562: e / AndroidRuntime (32042): java.lang.RuntimeException: activity unable to start ComponentInfo {com.OptimusApps.stayhealthy / com.OptimusApps.stayhealthy.MainActivity}: java.lang.NullPointerException 06-22 21 : 44: 21.562: e / AndroidRuntime (32042): on android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2079) 06-22 21: 44: 21.562: e / AndroidRuntime (32042): android.app.ActivityThread.handleLaunchActivity (ActivityThread.java.10104) 06-22 21: 44: 21.562: E / Android Random (32042): Android. On the App ActiveTrade.X $ 600 (ActivityTrad.JePower 32) 06-22 21: 44: 21.562: E / Android Time (32042): Android. App Aktivititrerad HK $ Hondl message (Gtividhitredkjawaprati 157) 06-22 21: 44: 21.562: E Androidrentaim (32042): Androidkoskhandlr Dispatch Message (Handlrkjawa: 99) 06-22 21: 44: 21.562: E / Android Rendime (32042): Android. On Los Looper Loop (Looper.java:137) 06-22 21: 44: 21.562: E / Android Random (32042): Android. App ActiveTatrad.mine (ActivityTrad.Java 4575) 06-22 21: 44: 21.562: E / Android Time (32042): at java.lang.reflect Method. Nivek (Native Method) 06-22 21: 44: 21.562: E / Android Random (32042): at java.lang.reflect.Method.invoke (Method. Java T-1111) 06-22 21: 44: 21.562: E / AndroidRuntime (32042): com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:789) at 06-22 21: 44: 21.562: E / AndroidRuntime (32042): at com.android.internal 62.jygoteInit.main (ZygoteInit.java/56) 06-22 21: 44: 21.562: E / Android Random (32042): On Dalvik.system.NativeStart.main (Basic Method) 06-22 21: 44: 21.562: e / AndroidRuntime (32042): caused by: java.lang.NullPointerException 06-22 21: 44: 21.562: e / AndroidRuntime (32042): com.OptimusApps.stayhealthy.MainActivity.onCreate (MainActivity.java:40) 06 - 22 21: 44: 21.562: E / Android Random (32042): Android. App Active.Perform Create (Activity.Java 4465) 06-22 21: 44: 21.562: E / Android Time (32042): On Android.App I'm 06-22 on nstrumentation.callActivityOnCreate (Instrumentation.java:1049) 06-22 21: 44: 21.562: E / AndroidRuntime (32042): android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2033) 21: 44: 21.562 : E / AndroidRuntime (32042): ... 11 more    

logs a NullPointerException , So it is possible that typefaces have not been loaded correctly. Can you verify that your robotomed.tff is actually in your project's / asset ?

Check for more information about the property.

No comments:

Post a Comment