How to create a TwoLineListItem file?

I want to make the settings menu as follows:

enter image description here

Is there a definitive guide on how to make TwoLineListItem anywhere?

+6
source share
5 answers

In your case, add the PreferenceActivity and the onCreate method:

 @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); addPreferencesFromResource(R.xml.preferences); getPreferences(); } 

If you can inflate your presentation using the preferences.xml file - add a folder called xml to your res folder and add an xml file with materials such as:

 <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 final is the second line.

+2
source

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

+3
source

You need custom View and ListActivity . This tutorial can help. If you are working on settings activity, why not extend PreferenceActivity ?

+1
source

Here's a pretty good tutorial on how to create custom list items. The basic idea is that you define the layout of the list item in the same way that you define the layout for an Activity . Then you add a subclass of ArrayAdapter (or BaseAdapter ) and override the getView(...) method to return your own View list item.

0
source

I had a similar problem, but my desired list item should have an image followed by two lines, one above the other (as you want). I found a solution here . It worked easily for me, and I think it will work well for you (you just need to remove the ImageView part accordingly).

0
source

Source: https://habr.com/ru/post/895442/


All Articles