在我试图在<条形码>内显示“ProgressDial(简单、次要的类型)”时,我便提出一个非常有趣的问题。
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
in this case)完成为止。 我做了什么错误?