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){
// set refresh application in each 1 minute according to current time
}
else if(idx==1)
{
// set refresh application in each 10 minute according to current time
}
else if (idx==2)
{
// set refresh application in each 1 hour according to current time
}
else
{
// set refresh application in each 24 hour according to current time
}
return true;
}
});
我必须在设置中使用它,请告诉我我将如何应用线程或其他东西,以便我们的应用程序在每 1、1、10 分钟内刷新一次……根据列表首选项中的设置,请向我发布代码。