FileDocCategorySizeDatePackage
ListPreferenceTest.javaAPI DocAndroid 5.1 API1536Thu Mar 12 22:22:12 GMT 2015android.preference

ListPreferenceTest

public class ListPreferenceTest extends android.test.AndroidTestCase

Fields Summary
Constructors Summary
Methods Summary
public voidtestListPreferenceSummaryFromEntries()

        String[] entries = { "one", "two", "three" };
        String[] entryValues = { "1" , "2", "3" };
        ListPreference lp = new ListPreference(getContext());
        lp.setEntries(entries);
        lp.setEntryValues(entryValues);

        lp.setValue(entryValues[1]);
        assertTrue(lp.getSummary() == null);

        lp.setSummary("%1$s");
        assertEquals(entries[1], lp.getSummary());

        lp.setValue(entryValues[2]);
        assertEquals(entries[2], lp.getSummary());

        lp.setSummary(null);
        assertTrue(lp.getSummary() == null);

        lp.setSummary("The color is %1$s");
        assertEquals("The color is " + entries[2], lp.getSummary());