当我尝试在侦听器中显示一个ProgressDialog
(简单的微调器类型)时,我遇到了一个非常有趣的问题。onPreferenceChange
public class SettingsActivity extends PreferenceActivity {
private ProgressDialog dialog;
public void onCreate(Bundle savedInstanceState) {
ListPreference pref= (ListPreference) findPreference("myPreference");
pref.setOnPreferenceChangeListener(new OnPreferenceChangeListener() {
@Override
public boolean onPreferenceChange(Preference preference, Object newValue) {
dialog = ProgressDialog.show(SettingsActivity.this, "", "Doing stuff...", true);
SystemClock.sleep(2000);
}
return true;
}
}
出现ProgressDialog
,但直到方法(sleep
在这种情况下)完成。我究竟做错了什么?