I want to make a setings menu like this:
Is there a definitive guide on how to make TwoLineListItem
's anywhere?
You will need to use a custom listrow with a custom adapter.
Here is an example: http://geekswithblogs.net/bosuch/archive/2011/01/31/android---create-a-custom-multi-line-listview-bound-to-an.aspx
In your case, extend PreferenceActivity and in the onCreate method:
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
addPreferencesFromResource(R.xml.preferences);
getPreferences();
}
Where you can inflate your view using a preferences.xml file - add a folder called xml to your res folder and add an xml file with stuff like:
<CheckBoxPreference
android:title="@string/pref_sub_notify"
android:defaultValue="true"
android:summary="@string/pref_sub_notify_summary"
android:key="subNotifyPref" />
<ListPreference
android:title="@string/pref_sub_expiry_warn"
android:summary="@string/pref_sub_expiry_summary"
android:key="subExpiryDelayPref"
android:defaultValue="7"
android:entries="@array/sub_expiry_delay"
android:entryValues="@array/sub_expiry_delay_values" />
In this case, the title is your first line and the summary is the second line.
You need a custom View
and a ListActivity. This tutorial may help. If you are working on a Settings Activity, why not extend PreferenceActivity?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With