Created
November 26, 2015 21:22
-
-
Save Nutomic/b40eb047002715f54e57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.nutomic.syncthingandroid.preferences; | |
import android.content.Context; | |
import android.preference.MultiSelectListPreference; | |
import android.util.AttributeSet; | |
import android.view.View; | |
import android.widget.ArrayAdapter; | |
import android.widget.ListAdapter; | |
import android.widget.ListView; | |
public class DynamicListPreference extends MultiSelectListPreference { | |
public DynamicListPreference(Context context, AttributeSet attrs) { | |
super(context, attrs); | |
} | |
@Override | |
protected View onCreateDialogView() { | |
ListView view = new ListView(getContext()); | |
view.setAdapter(adapter()); | |
setEntries(entries()); | |
setEntryValues(entryValues()); | |
return view; | |
} | |
private ListAdapter adapter() { | |
return new ArrayAdapter<String>(getContext(), android.R.layout.select_dialog_singlechoice); | |
} | |
private CharSequence[] entries() { | |
return new CharSequence[] {"test1", "test2", "test3"}; | |
} | |
private CharSequence[] entryValues() { | |
return new CharSequence[] {"test1", "test2", "test3"}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment