The Gradle dependency is available via jCenter.
dependencies {
// ... other dependencies here
compile 'com.ksxkq:materialpreference:1.0.5'
}
布局文件中添加
<com.ksxkq.materialpreference.widget.PreferenceContainer
android:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent" />
PreferenceContainer container = (PreferenceContainer) findViewById(container);
- CategoryPreference
container.addCategoryPreference("key", "title");
- SwitchPreference
container.addSwitchPreference("key", "title");
- CheckboxPreference
container.addCheckBoxPreference("key", "title");
- ScreenPreference
container.addScreenPreference("key", "title");
- SeekBarPreference
container.addScreenPreference("key", "title", defaultValue, maxValue);
- ListPreference
container.addCategoryPreference("key", "title", itemNames, itemValues);