I am developing an android app and I noticed I use the same dialogs in different fragments/Activities.
I was trying to wrap it in a class but my app is crashing whenever is time to show the dialog. Any ideas?
dialog class
public class Diaglogs {
+
+ private Context context;
+
+ public Diaglogs(Context context) {
+ this.context = context;
+ }
+
+ public void createPlaylistDialog() {
+ AlertDialog.Builder builder = new AlertDialog.Builder(context);
+ builder.setTitle("Enter name of the playlist");
+
+ // Set up the input
+ final EditText input = new EditText(context);
+
+ // Specify the type of input expected; this, for example, sets the input as a password, and will mask the text
+ input.setInputType(InputType.TYPE_CLASS_TEXT);
+ builder.setView(input);
+
+ // Set up the buttons
+ builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ String playListName = input.getText().toString();
+ if (!"".equals(playListName)) {
+ Toast.makeText(context, "the c=playlist would be created here", Toast.LENGTH_SHORT);
+ } else {
+
+ }
+ }
+ });
+ builder.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
+ @Override
+ public void onClick(DialogInterface dialog, int which) {
+ dialog.cancel();
+ }
+ });
+ builder.show();
+ }
+
+}
error
java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.