Define PreferenceScreen in xml file : Xml « Development « Android






Define PreferenceScreen in xml file

     


package app.test;

import android.os.Bundle;
import android.preference.PreferenceActivity;

public class Test extends PreferenceActivity
{
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.main);
    }
}

//xml/main.xml

<?xml version="1.0" encoding="utf-8"?>
<!-- This file is /res/xml/chkbox.xml -->
<PreferenceScreen
    xmlns:android="http://schemas.android.com/apk/res/android"
  android:key="flight_columns_pref" 
  android:title="Flight Search Preferences"
  android:summary="Set Columns for Search Results">
  <CheckBoxPreference
      android:key="show_airline_column_pref"
    android:title="Airline"
    android:summary="Show Airline column" />
  <CheckBoxPreference
      android:key="show_departure_column_pref"
    android:title="Departure"
    android:summary="Show Departure column" />
  <CheckBoxPreference
      android:key="show_arrival_column_pref"
    android:title="Arrival"
    android:summary="Show Arrival column" />
  <CheckBoxPreference
      android:key="show_total_travel_time_column_pref"
    android:title="Total Travel Time" 
    android:summary="Show Total Travel Time column" />
  <CheckBoxPreference
      android:key="show_price_column_pref"
    android:title="Price" 
    android:summary="Show Price column" />
</PreferenceScreen>

   
    
    
    
    
  








Related examples in the same category

1.Using xml resource
2.XML Resource Demo
3.Load style from styles.xml
4.Using XML Parser
5.XML-defined adapters can be used to easily create adapters in your own application or to pass adapters to other processes.
6.Xml Parse
7.Xml Serializer Uri
8.Get Text Content from Xml Node
9.Escape un escape Xml
10.Get Xml node value with substring
11.Get value from Element
12.Get attribute value
13.Get field from NamedNodeMap
14.get Node Value With Attribute
15.get Character Data From Element
16.update Xml