Crashed when applied Toolbar

前端 未结 3 1242
Happy的楠姐
Happy的楠姐 2021-01-05 10:06

I\'m new in Android programming. I\'m having this issue when I applied the toolbar into my app and it crashed when I try to run the app. Here is the code:

To         


        
相关标签:
3条回答
  • 2021-01-05 10:35

    You can see in your logcat output the answer:

    Do not request Window.FEATURE_ACTION_BAR, set windowActionBar to false in your theme to use a Toolbar instead.

    Also try using this link and this link

    make sure you use this:

     <item name="windowActionBar">false</item> 
    

    in your theme

    0 讨论(0)
  • 2021-01-05 10:36

    Try this fix, it worked for me:

    Link to the StackOverFlow answer

    Also check for the below link for using AppCompat:

    Reference link for the AppCompat library

    0 讨论(0)
  • 2021-01-05 10:55

    If you use Toolbar from v7-support, you should use Theme.AppCombat in your Activity.

    Define your style in styles.xml

    <style name="AppTheme" parent="Theme.AppCompat">
        <item name="colorPrimary">@color/black</item>
    </style>
    <color name="black">#000000</color>
    

    And apply it to whole application (or specyfic Activity) in AndroidManifest.xml

    <application
            android:icon="@drawable/ic_launcher"
            android:label="@string/app_name"
            android:theme="@style/AppTheme" >
    
    0 讨论(0)
提交回复
热议问题