Android ActionBarCompat library -
i'm having trouble using actionbarcompat support library released yesterday. have updated support repository , included path appcompat-v7 repository in build.gradle chris banes pointing out in devbytes - https://www.youtube.com/watch?v=6tggyqfjnyc .
dependencies { compile ('com.android.support:support-v4:18.0.+') compile ('com.android.support:appcompat-v7:18.0.+')}
build goes , can use classes such actionbaractivity library cannot use styles , resources cannot use following themes - @style/theme.appcompat etc. thinking i'll find source files in .../sdk/extras/android/.../"supportrepo" reference actionbarsherlock gradle didn't seems correct answer.
what doing wrong? thank you.
i'm using android studio , have same res-resolving issue in values/styles.xml
.
it says cannot resolve @style/theme.appcompat.light
, @ compile-time (gradle) , runtime works fine (android 2.3.3 & 4.3).
i'd rid of warning res cannot resolved.
how can tell android studio res can found in appcompat-v7 repo?
(this question related bug in android studio has been fixed.)
below see did. hope help. suggestions appreciated.
the source appcompat library can found on github.
gradle integration:
dependencies { ... compile group:'com.android.support', name:'appcompat-v7', version:'18.0.+' ... }
style-files:
values/styles.xml:
<resources> <!-- base application theme, dependent on api level. theme replaced appbasetheme res/values-vxx/styles.xml on newer devices. --> <style name="appbasetheme" parent="android:theme.holo.light"> <!-- theme customizations available in newer api levels can go in res/values-vxx/styles.xml, while customizations related backward-compatibility can go here. --> </style> <!-- application theme. --> <style name="apptheme" parent="@style/theme.appcompat.light"> <item name="actionbarstyle">@style/actionbar.solid.custom</item> </style> <style name="actionbar.solid.custom" parent="@style/widget.appcompat.light.actionbar.solid"> <item name="background">@drawable/ab_solid_custom</item> <item name="displayoptions">homeasup|showhome|showcustom</item> </style> </resources>
values-v14/styles.xml:
<resources> <!-- base application theme api 14+. theme replaces appbasetheme both res/values/styles.xml , res/values-v11/styles.xml on api 14+ devices. --> <style name="appbasetheme" parent="android:theme.holo.light"> <!-- api 14 theme customizations can go here. --> </style> <!-- application theme. --> <style name="apptheme" parent="@style/theme.appcompat.light"> <item name="android:actionbarstyle">@style/actionbar.solid.custom</item> </style> <style name="actionbar.solid.custom" parent="@android:style/widget.holo.light.actionbar.solid"> <item name="android:background">@drawable/ab_solid_custom</item> <item name="android:displayoptions">homeasup|showhome|showcustom</item> </style> </resources>
mainactivity (only extend mandatory):
public class mainactivity extends actionbaractivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main); views.inject(this); setupnavigationdrawer(); } }
androidmanifest.xml (setting android:theme mandatory):
<activity android:name="com.example.app.mainactivity" android:theme="@style/apptheme" android:label="@string/app_name" > <intent-filter> <action android:name="android.intent.action.main" /> <category android:name="android.intent.category.launcher" /> </intent-filter> </activity>
Comments
Post a Comment