我有一些tabpages和片段。這些片段包含一個元素。在獲取圖像緩存和填充gridviews自定義網格後,我的程序將進入web服務並讀取json數據。如何在Android碎片中顯示ProgressDialog?
現在,怎樣才能顯示ProgressDialog只完成碎片?我怎麼能解僱progressDialog GridView填充將完成?
My Fragment OnCreate Method;
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View v = inflater.inflate(R.layout.fragment_b, container, false);
context = getActivity();
final ProgressDialog dialog = ProgressDialog.show(context, "", "Please wait, Loading Page...", true);
GridView gridView = (GridView) v.findViewById(R.id.gridview);
if (isConnected()) {
try {
new ProgressTask(context).execute();
gridView.setAdapter(new AdapterB(context, WallPaperList));
} catch (NullPointerException e) {
e.printStackTrace();
return v;
}
} else {
Toast.makeText(v.getContext(), "Please check your internet connection..!", Toast.LENGTH_LONG).show();
}
return v;
}
最好的辦法是使用'的AsyncTask ' –
可能可以使用接口 –