1.配置Preference.xml文件
<?xml version="1.0" encoding="utf-8"?>
<PreferenceScreen
xmlns:android="http://schemas.android.com/apk/res/android">
<CheckBoxPreference android:summaryOn="kaiqi" android:key="test"></CheckBoxPreference>
<CheckBoxPreference android:summaryOn="kaiqi" android:key="test"></CheckBoxPreference>
<CheckBoxPreference android:summaryOn="kaiqi" android:key="test"></CheckBoxPreference>
<CheckBoxPreference android:summaryOn="kaiqi" android:key="test"></CheckBoxPreference>
<CheckBoxPreference android:summaryOn="kaiqi" android:key="test"></CheckBoxPreference>
<CheckBoxPreference android:summaryOn="kaiqi" android:key="test"></CheckBoxPreference>
<CheckBoxPreference android:summaryOn="kaiqi" android:key="test"></CheckBoxPreference>
<CheckBoxPreference android:summaryOn="kaiqi" android:key="test"></CheckBoxPreference>
<CheckBoxPreference android:summaryOn="kaiqi" android:key="test"></CheckBoxPreference>
<CheckBoxPreference android:summaryOn="kaiqi" android:key="test"></CheckBoxPreference>
</PreferenceScreen>
2.底部button按钮的layout文件 ,其中layout文件必须包含listview控件,且ID为list。
<ListView android:id="@android:id/list" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_weight="1" android:drawSelectorOnTop="false" />
Placeholder to get blank space between the two buttons-->
public class CustomProfile extends PreferenceActivity{
private BatteryProfileUtils mBatteryProfileUtils;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.buttonbar);//使用布局文件
addPreferencesFromResource(R.xml.configuration);加载配置文件
getListView().setItemsCanFocus(true);
Button enable=(Button)findViewById(R.id.button1);
enable.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stu
}
});
Button disable=(Button)findViewById(R.id.button2);
disable.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View arg0) {
// TODO Auto-generated method stub
finish();
}
});
}
}
参考Android闹钟源码