How to cancel or reject user dialog in onCreate method?

I created a custom dialog MyCustomDialogthat extends Dialog. I create and display my own dialog box as follows:

new MyCustomDialog(myContext).show();

I override the method Dialog.onCreate(Bundle savedInstanceState)to complete my initialization. I also check this method to see if a condition is met, and if not, I would like to reject / cancel my dialog. I tried to call methods cancel()and dismiss()in my conversations onCreate(Bundle savedInstanceState)and onStart(), but it has no effect.

Does anyone know how to cancel or reject a dialog (from a dialog box) before displaying it?

+5
source share
2 answers

, , onCreate(). .

show() showIfRequired() ( - ) show.

, , , , - . , .

DialogFragment Dialog. v4.

+2

API 10 :

onCreateDialog (int id, Bundle args) Activity, , ? Activity. -, , / onCreateDialog, onCreateDialog. / , . onPrepareDialog() , / . ( ), , / .

onPrepareDialog() - , . API Honeycomb.

API 11 :

API, DialogFragment. , onCreateView() DialogFragment, onPrepareDialog().

, : http://developer.android.com/guide/topics/ui/dialogs.html

, API:

http://developer.android.com/reference/android/app/DialogFragment.html

, , , ? , Dialog.show() , . , . , , Dialog.show() onClickListener. , , , - , . , , - - .

+1

All Articles