How do I apply the HoloEverywhere android theme when using ActionBarSherlock?
T

3

12

I'm building an application that should work on android 2.3 and I added both ActionBarSherlock and HoloEverywhere libraries.

In order to use ActionBarSherlock I have to use Theme.Sherlock like so :

<application
    ...
    android:theme="@style/Theme.Sherlock"
    ...  >

And that's ok.

My main activity is pretty simple : just a ListView with 5 rows (I don't use ListAcivity).

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <ListView
        android:id="@+id/menuListView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

</LinearLayout>

Since it's android 2.3, I still have the orange&black theme (except for the ActionBar of course). Now I want to add the HoloEverywhere theme by modifying my manifest like so :

<application
    ...
    android:theme="@style/Theme.HoloEverywhereDark.Sherlock"
    ...  >

BUT that does not change anything... What am I missing ?

Touslesmois answered 27/7, 2012 at 6:46 Comment(4)
i need the spinner like ICS in previous versions. But i tried importing ActionBarSherlock and Holoeverywhere. But in eclipse after importing throwing lot of errors. And also please tell can't we just use holoeverywhere without ActionBarSherlock ?Selective
which errors? and yes you can use Holoeverywhere without actionbarsherlockTouslesmois
Like resource not found errors. Step i did to import is->File->New Project->Android Project From Existing code.Selective
Check that the R.java file is correctly generated, sometimes it's not. Also you should set ActionBarSherlock project as a library in the properties of HoloEverywhere project.Touslesmois
T
7

To enable the Holo theme by default for every ListView I went in the styles.xml file of the HoloEverywhere library then I modified the "ListViewStyle" element by adding this line :

<item name="android:listSelector">@drawable/list_selector_holo_dark</item>
Touslesmois answered 27/7, 2012 at 13:13 Comment(0)
C
3

I had the same issue with ListView's selector. I though that HoloEveruwhere would apply holo selector(blue) by default(I have tried both Theme.HoloEverywhereLight and Theme.HoloEverywhereLight), but it didn't. Maybe I am missing something.

I ended up setting the selector manually:

listView.setSelector(R.drawable.list_selector_holo_light);

You have several drawable resources in the library you can make use of(list_selector_holo_light for example).

Cestode answered 27/7, 2012 at 10:34 Comment(1)
that's actually working but then I have to do it for each ListView.Touslesmois
A
2

A portable and correct solution would be to inherit from ListViewStyle and override the attribute, making this in your styles.xml.

If you had HoloEverywhere official library deployed remotely on a server (e.g. Maven repo) you could not depend on it mantaining a change in the styles.xml (you are modifying it for your own needs).

Authenticate answered 5/12, 2012 at 19:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.