Is it possible to change background color of Preference

by Vincent » Tue, 16 Feb 2010 19:33:17 GMT


Sponsored Links
 Hi,

Does anybody know how to change the background color of Preference
(PreferenceCategory, EditTextPreference ...) ?

I wanna do like this:
<PreferenceCategory android:title="title_test"
android:background="@color/testColor">
But this doesn't work...
I searched these by using google, but couldn't find any right
answer...

Also, I couldn't find any way to change other layouts. (e.g. text
color, size and style of preference title or summary)
Is there no way to customize the layout of Preferences?
It'll be great if somebody can help me out.

thanks in advance!

--



Is it possible to change background color of Preference

by Bob Kerns » Wed, 17 Feb 2010 00:23:02 GMT


 I think you'll need to supply the android:layout attribute, and supply
an alternative layout with the background set.

You can find the default layout in the SDK at platforms/android-2.1/
data/res/layout/preference.xml

If you just want to customize the widget portion, use
android:widgetLayout instead, but this sounds like you want to affect
the entire preference.




--


Sponsored Links


Is it possible to change background color of Preference

by joebowbeer » Wed, 17 Feb 2010 05:51:28 GMT


 Something like this:

public class MyPreferenceActivity extends PreferenceActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
 
getWindow().setBackgroundDrawableResource(R.drawable.my_background);
        getListView().setBackgroundColor(Color.TRANSPARENT);
        getListView().setCacheColorHint(Color.TRANSPARENT);
        getPreferenceManager().setSharedPreferencesName("my_prefs");
        addPreferencesFromResource(R.xml.my_preferences);
    }

I'm not sure if the listView changes are necessary or advisable.

Joe




--



Is it possible to change background color of Preference

by skink » Wed, 17 Feb 2010 07:09:36 GMT


 



i'm afraid it works only for top-level preferences.

if you have inner ScreenPreferences it won't work as ScreenPreferences
use Dialogs in order to show their child Preferences

pskink

--



Is it possible to change background color of Preference

by Vincent » Wed, 17 Feb 2010 13:31:50 GMT


 Bob, joebowbeer, skink

Thanks so much for your help!!
I successfully managed to change the layout of preference.

As joebowbeer wrote, I changed the top-level background image and
listview setting in my code like below.
 
getWindow().setBackgroundDrawableResource(R.drawable.my_background);
        getListView().setBackgroundColor(Color.TRANSPARENT);
        getListView().setCacheColorHint(Color.TRANSPARENT);

Then, I supplied the custom layout to the android:layout attribute in
xml in order to change other child preferences as Bob stated.
    <PreferenceScreen xmlns:android=" http://schemas.android.com/apk/ 
res/android">
        <PreferenceCategory android:title="test_title"
android:layout="@xml/preference_category">
            <EditTextPreference
                android:key="edit_key"
                android:title="edit_title"
                android:summary="edit_summary"
                android:layout="@xml/preference"
                />
        </PreferenceCategory>
    </PreferenceScreen>


Thank you very much!!








--



Other Threads

1. Does one really need to have a data plan with G1 if you use Wifi + voice?

I just spoke with a T-mobile rep and she says that "in order for the
phone to work, you have to have the data plan because without internet
access, you will not even be able to make phone calls because you have
to sign on to your google account to sign into the phone".
So one cannot make voice calls without internet access to first sign
in? that seems really ridiculous to me. Is that accurate? Can anyone
with a G1 and without a data plan verify?

On Mar 10, 1:48pm, "Michael Martin - MM Agency" <mi...@mm-agency.com>


--~--~---------~--~----~------------~-------~--~----~

2. Using JUnit

Hi friends

I am working on Android application. I want to develop applications using
the Test Driven Development (TDD).
I have found that Android sdk supports JUnit. I have also seen the test
folder in each sample application provided by the Google.

Please tell me the step by step approach to using JUnit. I have tried a lot
but failed to do so. I don't want to use third party tools like Positron and
p-Unit.

Thanks
Pankaj

--~--~---------~--~----~------------~-------~--~----~

3. Clarification about system images

4. Ifconfig command in Adb shell

5. Regarding the Network Location provider basic initialization sequence

6. Let the touch events pass through my application, Was it possible?

7. Regarding the Network Location provider basic initialization sequence