Advertisement
Guest User

Untitled

a guest
Aug 21st, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. <activity
  2. android:name="Activity"
  3. android:theme="@style/customDialog" />
  4.  
  5. <style name="customDialog" parent="Theme.AppCompat.Light.Dialog.Alert">
  6. <item name="windowNoTitle">true</item>
  7. <item name="colorAccent">@color/colorPrimary</item>
  8. <item name="android:textColorPrimary">@color/colorNegro</item>
  9. <item name="android:windowBackground">@android:color/transparent</item>
  10. </style>
  11.  
  12. public class CustomDialog extends Dialog {
  13.  
  14. Button button;
  15. TextView textview;
  16.  
  17.  
  18. private View view;
  19.  
  20.  
  21. public CustomDialog (Context context, Activity activity, String message, String text_button){
  22. super(context);
  23.  
  24. view = LayoutInflater.from(context).inflate(R.layout.custom_dialog, null);
  25. getWindow().setBackgroundDrawable(context.getResources().getDrawable(R.drawable.transparent_back));
  26. setContentView(view);
  27.  
  28. button = (Button) view.findViewById(R.id.button);
  29. textview = (TextView) view.findViewById(R.id.textview);
  30.  
  31. setDataOnWidgets(message,text_button);
  32.  
  33. }
  34.  
  35. public void setDataOnWidgets(String message, String text_button){
  36. textview.setText(message);
  37. button.setText(text_button);
  38.  
  39. }
  40.  
  41.  
  42.  
  43. public void setButton(View.OnClickListener listener){
  44. button.setOnClickListener(listener);
  45.  
  46. }
  47.  
  48. final CustomDialog dialog = new CustomDialog(
  49. Activity.this,
  50. Activity.this,
  51. message,
  52. text_button);
  53.  
  54. alert.setCancelable(false);
  55. alert.setButton(new View.OnClickListener() {
  56. @Override
  57. public void onClick(View v) {
  58.  
  59. }
  60. });
  61.  
  62. alert.show();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement