2
AsyncTask
내부에서 진행 대화 상자 단편을 업데이트해야합니다. 이전 ProgressDialog
을 사용하여이 작업을 수행하는 방법을 알고 있지만 이제는 대화 상자를 표시하는이 방법이 사용되지 않으며 Fragments와 동일한 작업을 수행하려고합니다. ProgressDialog 단편을 업데이트하는 방법
이
는 조각 코드 :public static class CustomProgressDialogFragment extends SherlockDialogFragment {
static CustomProgressDialogFragment newInstance(Object... params){
CustomProgressDialogFragment df = new CustomProgressDialogFragment();
Bundle bundle = new Bundle();
// Populate bundle with params (not shown)
df.setArguments(bundle);
return df;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.setCancelable(false);
int style = DialogFragment.STYLE_NORMAL, theme = 0;
setStyle(style,theme);
}
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
Bundle bundle = this.getArguments();
ProgressDialog dialog = new ProgressDialog(getActivity());
// Get params from bundle and customize dialog accordingly (not shown)
dialog.setCancelable(false);
dialog.setIndeterminate(false);
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
return dialog;
}
}
이 내가 그것을 보여주는 방법입니다
FragmentTransaction ft = this.getSupportFragmentManager().beginTransaction();
CustomProgressDialogFragment dialogFragment = CustomProgressDialogFragment.newInstance(<My params here>);
ft.disallowAddToBackStack();
ft.add(dialogFragment, stringSet.tag);
ft.commitAllowingStateLoss();
가 지금은 AsyncTask를에서 대화를 통해
incrementProgressBy
를 호출해야합니다. FragmentManager에서 기본 대화 상자를 검색하는 방법이 있습니까? 이 일을하는 올바른 방법은 무엇입니까? (대화 상자가 다시 만들어지면 참조가 누출되고 싶지 않습니다.)
미리 감사드립니다.