嘿,我正在尝试让 ProgressDialog 工作,同时我从网络上获取 XML。问题是一旦加载和显示 XML,对话框就会显示出来。如果我之后关闭它,它根本不会出现。有什么想法该怎么做?我是android开发的新手,这是我的第一个应用程序,我已经在网上搜索过,但没有找到任何可行的解决方案。这是缩短的代码:
public class showReleases extends Activity {
SitesList sitesList = null;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.releasedetails);
ProgressDialog dialog = new ProgressDialog(showReleases.this);
dialog.setMessage("please wait");
dialog.setIndeterminate(true);
dialog.setCancelable(false);
dialog.show();
getFeed2();
dialog.dismiss();
}
public void getFeed2() {
Bundle extras = getIntent().getExtras();
try {
SAXParserFactory spf = SAXParserFactory.newInstance();
SAXParser sp = spf.newSAXParser();
XMLReader xr = sp.getXMLReader();
URL sourceUrl = new URL("http://www.it-leaked.com/app/details.php?id=" + extras.getString("id"));
MyXMLHandler myXMLHandler = new MyXMLHandler();
xr.setContentHandler(myXMLHandler);
xr.parse(new InputSource(sourceUrl.openStream()));
} catch (Exception e) {
System.out.println("XML Pasing Excpetion = " + e);
}
sitesList = MyXMLHandler.sitesList;
TextView txtView = (TextView)findViewById(R.id.TextView01);
txtView.setText(sitesList.getTitle().get(0));
TextView txtView2 = (TextView)findViewById(R.id.TextView02);
String myTracklist = sitesList.getTracklist().get(0);
myTracklist = myTracklist.replace("||||", "\n");
txtView2.setText(myTracklist);
}
}
提前致谢