• Solo Great Sale

    Solo Great Sale Powered By Circle Card 2015

  • Solo Great Sale

    Solo Great Sale Powered By Circle Card 2015

  • Oracle Java Magazine

    As Cover of Oracle Java Magazine March/April 2012 issue

  • Launching jDuchess Indonesia

    Gunadarma University 2011

    www.jduchess.or.id

  • Launching jDuchess Indonesia

    Gunadarma University 2011

    www.jduchess.or.id

  • Launching Java 7

    Binus University 2011

  • Eclipse Democamp

    Microsoft Indonesia 2011

  • Oracle Academy

    SMK PGRI 3 Malang 2010

  • Launching JENI 2.0

    ITB Bandung 2012

  • Oracle Academy

    SMK PGRI 3 Malang 2010

  • Java and Android Roadshow

    SMK PGRI 3 Malang 2012

  • Oracle Academy

    SMK PGRI 3 Malang 2010

  • Launching JENI 2.0

    ITB Bandung 2012

  • Oracle Academy

    SMK PGRI 3 Malang 2011

  • Java and Android Roadshow

    SMK Plus Darussalam Kediri 2012

  • Oracle Academy Seminar

    LIKMI Bandung, 2012

  • Oracle Academy Seminar

    Indonesia University, 2012

  • Seminar Android

    Universitas Budi Luhur 2010

  • Java and Android Roadshow

    SMK Hasan Kafrawi Jepara 2012

  • Sosialisasi Kurikulum 2013

    LPMP Surabaya 2013

  • IOSA

    Indonesia Open Source Award 2011

  • Java Training

    SMKN 02 Sukabumi 2010

  • Sosialisasi Kurikulum

    SMKN 01 Tulungagung 2011

  • Sosialisasi Kurikulum 2013

    LPMP Surabaya 2013

Thursday, April 8, 2010

Posted by Netty Herawaty
| 6:50 AM
Android preference bisa dibuat melalui file xml maupun melalui class activity. Setiap preference memiliki properti android:title untuk judul preference dan android:summary untuk deskripsi dari preference tersebut.

1. Checkbox Preference

Sekarang kita menggunakan contoh penerapan preference pada file xml

main.xml

<?xml version="1.0" encoding="utf-8"?>

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

    android:summary="Set Columns for Search Results"

    android:title="Flight Search Preferences" >



    <CheckBoxPreference

        android:summary="Show Airline column"

        android:title="Airline" />



    <CheckBoxPreference

        android:summary="Show Departure column"

        android:title="Departure" />



    <CheckBoxPreference

        android:summary="Show Arrival column"

        android:title="Arrival" />



    <CheckBoxPreference

        android:summary="Show Total Travel Time column"

        android:title="Total Travel Time" />



    <CheckBoxPreference

        android:summary="Show Price column"

        android:title="Price" />

</PreferenceScreen>

CheckBoxPref.java

package android.preference;

import android.os.Bundle;

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




2. EditText Preference

Preference juga menyediakan preferensi text yang disebut EditTextPreference
<?xml version="1.0" encoding="utf-8"?>

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

    android:summary="Set package name"

    android:title="Package Name" >


    <EditTextPreference

        android:dialogTitle="Package Name"

        android:summary="Set the package name for generated code"

        android:title="Set Package Name" />


</PreferenceScreen>

3. Ringtone Preference

RingtonePreference digunakan untuk mengatur nada dering
<?xml version="1.0" encoding="utf-8"?>

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

    android:summary="Set Flight Option Preferences"

    android:title="My Preferences" >



    <RingtonePreference

        android:ringtoneType="alarm"

        android:showSilent="true"

        android:summary="Set Ringtone"

        android:title="Set Ringtone Preference" />



</PreferenceScreen>

4. Organizing Preference

Organizing Preference untuk mengatur preferensi ke dalam beberapa kategori. Anda dapat menggunakan PreferenceScreen atau PreferenceCategory


Reactions: