Android: How to/Tutorial for changing ActionBar to ActionBarCompat (Toolbar)? -


I got stuck on this, examined official guidance, etc. What are the steps to replace with any tutorials / actionbars? ActionBarCompat (for toolbar and to support older versions? I've imported AppCom-V7: 21.0., Try

< Code> getSupportActionBar (); and

  Toolbar Toolbar = (toolbar) Find ViewById (R.id.toolbar_actionbar); setSupportActionBar (toolbar);  

Changed theme for the theme in aesthetic theme ... Any common errors or ideas to note?

Keep an error like this:

JavaklangkRuntimeException: Unable to start the activity ComponentInfo {com.battery.plusfree / com.battery.plusfree .MainCollectionActivity}: android.app.ActivityThread.access android.app at $ 800 (ActivityThrea. on ActivityThread.performLaunchActivity (ActivityThread.java:2212) on android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2271) java.lang.NullPointerException d.java:144) android.app.ActivityThread $ H.handleMessage (ActivityThread.java : 1205) android.os.Handler.dispatchMessage (Handler.java:102) android.os.Looper.loop on android at (Looper.java: 136) at java.lang.ref.on.whichaative (the original method) android .app.ActivityThread.main (ActivityThread.java; 146) at java.lang.reflect.Method.invoke (Method.java / 15) at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run com.android.internal.os.ZygoteInit.main (ZygoteInit.java: 732) (ZygoteInit.java lesson66) at de.robv.android.xposed.XposedBridge Main dalvik.system.NativeStart.main (XposedBridge.java:132) (Native Method) due to: java.lang.NullPointerException at com.battery.plusfree.MainCollectionActivity.onCreate (MainCollectionActivity.java:133) android.app On. Gtividhikprform Create (Gtividhikjawas 3131) ndroid.app.ActivityThread.performLaunchActivity (ActivityThread.java:2169) on android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1087) on android.app.ActivityThread.handleLaunchActivity (ActivityThread. Java: 2271) at android.app.ActivityThread.access $ 800 (ActivityThread.java:144) at android.app at. Android.app.ActivityThread.main on android.os.Looper.loop (Looper.java:136) at ActivityThread $ H.handleMessage (ActivityThread.java:1205) android.os.Handler.dispatchMessage (Handler.java:102) (Activity.Thread.java; 146) java.lang.reflect.Method.invoke at native (native methode) at java.lang.reflect.Method.invoke (method.java less15) com.android.internal.os.ZygoteInit $ .run on MethodAndArgsCaller (Jhigoteinitkjawa: 732) (Jhigoteinitkjawa Pace on com.android.internal.os.ZygoteInit.main 66) Dalvik.system.NativeStart.main (Basic Law on de.robv.android.xposed.Xposed ) On Bridge.Man (EXPRESSBridge.JYR32)

I have learned from my application That you are the same You can not use the toolbar and the actionbars. So maybe that's where your issue is located, but I'm not sure because you have not posted your code, but using the styles.xml file, you either have to do this or do this:

  & lt; Style name = "Aaptim .base" parent = "theme compat." & Gt; & Lt; Item name = "color primary" & gt; @color/mycolprimery & lt; / Item & gt; & Lt; Item name = "color primary dark" & gt; @color/MycoolPrimary Dark & ​​lt; / Item & gt; & Lt; Item name = "android: windowNoTitle" & gt; True & lt; / Item & gt; & Lt; Item name = "windowActionBar" & gt; False & lt; / Item & gt; & Lt; / Style & gt;  

Activity.xml:

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; LinearLayout xmlns: Android = "http://schemas.android.com/apk/res/android" xmlns: custom = "http://schemas.android.com/apk/res-auto" Android: Orientation = "Vertical" Android: layout_width = "match_parent" Android: layout_height = "match_parent" & gt; & Lt ;! - Do not use it if you only want to use the actionbar - & gt; & Lt; android.support.v7.widget.Toolbar Android: id = "@ + id / toolbar" Android: Layout_height = "Wrap_content" Android: Layout_width = "Match_parent" Android: height = "5dp" Android: minHeight = "? Attr / Actionbirds "Android: Background ="? Entry / Color Priority "/> & Lt; / LinearLayout & gt;  

Activity. Java:

  Public class MyActivity ActionBarActivity Extended {Toolbar mToolbar; Crate on Public Zero (Bundle Saved InstantState) {// Configure Toolbars Accessories Setup PortAutumnbar; // or if you do not want to use Toolbar //, change the style values ​​accordingly, and then you instead of getSupportActionBar ()}}  

Reference: .. Hope it helps!


Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -