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.