[Java for Android App Development] jmz:
MainActivity:

import java.io.File;

import com.htc.preference.HtcPreference;

import com.htc.preference.HtcTwoStatePreference;

import com.htc.preference.HtcPreferenceActivity;

import com.htc.widget.ActionBarContainer;

import com.htc.widget.ActionBarExt;

import com.htc.widget.ActionBarText;

import com.htc.widget.HtcAlertDialog;

import android.os.Bundle;

import android.preference.PreferenceManager;

import android.provider.Settings;

import android.view.View;

import android.view.Window;

import android.content.DialogInterface;

import android.content.DialogInterface.OnClickListener;

import android.content.SharedPreferences;

public class MainActivity extends HtcPreferenceActivity implements HtcPreference.OnPreferenceClickListener {

public HtcTwoStatePreference led;

public HtcTwoStatePreference vibrate;

public SharedPreferences prefs;

private ActionBarExt actionBarExt=null;

private ActionBarText actionBarText=null;

private ActionBarContainer actionBarContainer=null;

public void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

addPreferencesFromResource(R.layout.activity_main);

check();

led = (HtcTwoStatePreference) findPreference("checkbox");

led.setOnPreferenceClickListener(this);

vibrate = (HtcTwoStatePreference) findPreference("vibrate");

vibrate.setOnPreferenceClickListener(this);

SetupActionBar();

}

public boolean onPreferenceClick(HtcPreference pref) {

if (pref == led) {

boolean value = led.isChecked();

if(value == true) {

//do stuff

}

if(value == false) {

//do stuff

}

}

if (pref == vibrate) {

boolean value = vibrate.isChecked();

if(value == true) {

//do stuff

}

if(value == false) {

//do stuff

}

}

return true;

}

private void SetupActionBar()

{

actionBarExt=new ActionBarExt(this,getActionBar());

actionBarExt.enableHTCLandscape(false);

actionBarContainer=actionBarExt.getCustomContainer();

actionBarText=new ActionBarText(this);

actionBarContainer.setBackUpEnabled(false);

actionBarText.setPrimaryText("myHUB OTA");

actionBarContainer.addCenterView(actionBarText);

actionBarContainer.setRightDividerEnabled(true);

actionBarContainer.setBackUpOnClickListener(new View.OnClickListener() {

public void onClick(View view) {

finish();

}

});

}

Layout XML:

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

<com.htc.preference.HtcPreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android">

<com.htc.preference.HtcPreferenceCategory android:title="Options" >

<com.htc.preference.HtcSwitchPreference

android:defaultValue="true"

android:key="checkbox"

android:summary="If enabled LED notifications will be shown"

android:title="Enable LED Notifications" >

</com.htc.preference.HtcSwitchPreference>

<com.htc.preference.HtcSwitchPreference

android:defaultValue="true"

android:key="vibrate"

android:summary="If enabled softkey vibrate will be enabled"

android:title="Enable Soft Key Vibration" >

</com.htc.preference.HtcSwitchPreference>

</com.htc.preference.HtcPreferenceCategory>

<com.htc.preference.HtcPreferenceCategory

android:title="StatusBar"

android:key="second_category">

<com.htc.preference.HtcEditTextPreference

android:key="statusbar_text"

android:title="test"

android:summary="test"

android:dialogTitle="test"

android:dialogMessage="Test"

android:defaultValue="ATT" />

</com.htc.preference.HtcPreferenceCategory>

</com.htc.preference.HtcPreferenceScreen>