如何在list pref选项中传递时间间隔

时间:2012-10-30 10:40:05

标签: android handler android-preferences

<ListPreference
 android:entries="@array/listOptions2"
 android:entryValues="@array/listValues2"
 android:key="listprefrefresh"
 android:summary="Set refresh the Application"
 android:title="Set Time Interval" />

    <item>10 </item>
    <item>30</item>

</integer-array>
<integer-array name="listValues2">
    <item>10000</item>
    <item>30000</item>
</integer-array>

这是我想要通过时间的代码我现在该如何实施?我正在传递整数值。请告诉我

public static final String PREF_BEER_SIZE2 = "listprefrefresh";
        Preference beerPref2 = (Preference) findPreference(PREF_BEER_SIZE2);
    beerPref2
                    .setOnPreferenceChangeListener(new Preference.OnPreferenceChangeListener() {

                        public boolean onPreferenceChange(Preference preference,
                                Object newValue) {
                            // TODO Auto-generated method stub

                            final ListPreference listrefresh = (ListPreference) preference;
                            final int idx = listrefresh
                                    .findIndexOfValue((String) newValue);

                            if (idx == 0 ) {
                                handler.post(timedTask);

                                //


                            } else if (idx == 1) {
                                // System.out.println("2");

                            } 
                            return true;
                        }
                    });

0 个答案:

没有答案