Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8305287
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:04:59+00:00 2026-06-08T18:04:59+00:00

I have a application in which i have a preference acitivty which loads my

  • 0

I have a application in which i have a preference acitivty which loads my settings xml. Now, what i want to do is implement a listview of themes to enable for the application. i know how to setup a listview in the settings xml for the most part, but i dont know how to enable different themes for the application. Can anybody point me in the right direction. or have a little sample code.

Here is my Preference JAVA file, and here below that is my Settings XML.

 public class Prefs extends PreferenceActivity {

ListPreference listPreference;

protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.settingsbasic);
        //New 
        Preference customPref = (Preference) findPreference("clearcache");
        customPref.setOnPreferenceClickListener(new OnPreferenceClickListener() {

                                public boolean onPreferenceClick(Preference preference)    {
                                        Toast.makeText(getBaseContext(),
                                                        "Cache Cleared",
                                                        Toast.LENGTH_LONG).show();
                                        WebViewClientDemoActivity.web.clearCache(true);
                                        return false; 

                                }       

I do not have my List view yet in the code, any help would be great on how to implement. I just have a clear cache button.

Here is my settings XML.

   <PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

    <CheckBoxPreference android:key="themes"
            android:title="@string/themes" 
            android:summary="@string/themes_list"
            android:defaultValue="true" />

    <CheckBoxPreference android:key="something"
             android:title="@string/cache" 
             android:summary="@string/somethingelse"
             android:defaultValue="true" />
    <Preference
            android:title="Clear Cache"
            android:summary="Hopefully this Works"
            android:key="clearcache" />

    </PreferenceScreen>

I have 2 check boxes, i want to change the first check box to a list view, and have a array of the list of themes. i just dont know how to enable these themes . Do i create seperate layout files for each theme??? or so i use the themes.xml, if so how do i impletement those by click the object in the listview???

Sorry about all the questions. Any help would be great.

main.xml file, i am wanting my theme to change the contents of this main.xml. most of the attributes will stay the same.

        <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:background="@drawable/boardimage"
  android:fadingEdge="vertical"
  android:orientation="vertical" >

  <ImageView
   android:layout_width="fill_parent"
   android:layout_height="wrap_content"
   android:background="@drawable/boarder"
   android:contentDescription="@string/title"
   android:gravity="center_horizontal"
   android:src="@drawable/banner" >

 </ImageView> 

  <ProgressBar
    android:id="@+id/progressBar1"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_gravity="center"/>

 <WebView
   android:id="@+id/webview01"
   android:layout_width="fill_parent"
   android:layout_height="0dp"
   android:layout_gravity="center"
   android:layout_weight="1.12" >

  </WebView>



  </LinearLayout>

So i want to know how i would go about changing the contents of this xml file. just as on my blue theme i will use a different drawable for the background or a different size of webview, or a image drawable in the imageview. how would i do that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:05:00+00:00Added an answer on June 8, 2026 at 6:05 pm

    If you want to know about themes and styles, see this link of android developer :
    http://developer.android.com/guide/topics/ui/themes.html

    build two styles and then give the value of setting from prefrence and switch between theme , you can set themes programmatically in your activity with this code : setTheme(R.style.MyTheme);

    You can do this with the following code in your themes.xml file in the values folder:

    <?xml version="1.0" encoding="utf-8"?>
    <resources>
    
        <style name="MyTheme" parent="@android:style/Theme.Light">
    
            <!-- hide the Window Title -->
            <item name="android:windowNoTitle">true</item>
    
        </style>
    
    </resources>
    

    And you can have a ListPreference with this code and add your string arrays in String.xml :

     <ListPreference
      android:title="List Preference"
      android:summary="Select the option of the list"
      android:key="listPref"
      android:entries="@array/listDisplayWord"
      android:entryValues="@array/listReturnValue" />
    

    This link is useful for you : How to add multiple theme attributes to the same activity on Android Manifest?

    You can use a value that give from your listPreference and switch between your layout, like this :

    if(myTheme==1)
         setContentView(R.layout.main1);
    else
         setContentView(R.layout.main2);
    

    but the name of components(buttons,textViews, EditText,…) in the these layout must same.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an application which has a Prefernces Class and I want to know
I have a growing web application which now needs to be able to store
I have a tablet application which I am rebranding so there are multiple themes,
I have an Android application in which I have my preferences in an XML
I have a preferences panel in my application in which I have a NSColorWell
I have a .net web application which has a reference to a web service.
I have application which uses Sherlock ActionBar package. The application uses platform-specific behavior for
I have application which needs to use a dll (also written by me) which
I have an application which uses the microsoft kinect device. The thing is that
I have an application which logs in into a webservice. I start a new

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.