Issue
i want to create a Method which creates a dialog in Android Studio, but i also want to pass in the name of the Dialog which should be used as the Dialogname. Until now i use the following metgod to create Dialogs:
Dialog DialogName = new Dialog(context);
//Parameters of the Dialog
//Parameters of the Dialog
//Parameters of the Dialog
//Parameters of the Dialog
//Parameters of the Dialog
DialogName.show();
But since the parameteres are the same everytime but the names of the dialoges change i just want to use a method to handle rest for me something like
create_dialog_method("my_new_Dialog",MainActivity.this);
//Some Other Code
my_new_Dialog.dismiss();
The method i want to declare outside of onCreate Method but within AppCompat would be something like:
private void create_dialog_method(String DialogName,Context context) {
Dialog DialogName = new Dialog (context);
//Other parameters which are the same for every dialog
//Other parameters which are the same for every dialog
//Other parameters which are the same for every dialog
//Other parameters which are the same for every dialog
//Other parameters which are the same for every dialog
DialogName.show();
}
Thanks in Regards for any help
Solution
The easiest approach to create custom dialogs is to create a new class named 'mycustomdialog' whşch extends the normal 'Dialog' Class from AppCompat in order to have same functionality. Then for parameters like width, length..... And all the parameters which should stay fixed for each dialog, I would set these properties within the 'mycustomdialog' Class and add a String parameter to the constructor of rhe class to set the different names.
Answered By - abdussamed17 Answer Checked By - Robin (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.