我想在 Detail 类在后台打开时按下我的列表视图的任何项目时显示一个 ProgressDialog,我知道我必须使用 asyncTask 但我不知道如何,有人可以帮我吗?
这是我展示 ProgressDialog 的片段
public class FeedPlayerIndexFragment extends SherlockFragment{
String url="http://www.toto.com/index.php?format=feed&type=rss";
ArrayList<Article> feeds ;
AndroidSaxFeedParser feedParser= new AndroidSaxFeedParser(url);
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Auto-generated method stub
feeds=feedParser.parse();
View view=inflater.inflate(R.layout.main, container, false);
CustomItemAdapter_News lfa = new CustomItemAdapter_News(getActivity().getApplicationContext(), feeds);
((ListView)view.findViewById(R.id.listFeed)).setAdapter(lfa);
((ListView)view.findViewById(R.id.listFeed)).setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView<?> arg0, View v, int position,long id) {
Bundle b = new Bundle();
b.putInt("position", position);
b.putString("url", url);
Intent intent=new Intent(getActivity().getApplicationContext(), DetailActivity.class);
intent.putExtras(b);
startActivity(intent);
}
});
return view;
}
}
这是我应该打开背景的详细活动
public class DetailActivity extends Activity{
String descriptionFinale = null,imageFinale = null,url;
int position;
TextView description_,titre,date;
ImageView image_;
ArrayList<Article> feeds ;
WebView contentWebView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.detail);
Bundle b = getIntent().getExtras();
position=b.getInt("position");
url=b.getString("url");
AndroidSaxFeedParser feedParser= new AndroidSaxFeedParser(url);
feeds=feedParser.parse();
date=(TextView) findViewById(R.id.date);
contentWebView= (WebView)findViewById(R.id.contentWebView);
titre=(TextView) findViewById(R.id.titre);
date.setText(feeds.get(position).getTitle());
GetDescriptionWebView.getDescriptionImage(position, feeds,contentWebView);
titre.setText("Postulé le: "+GetDateFormat.getDate(position, feeds));
}
}