Advertisement
chayanforyou

Android Custom Dialog

Jul 3rd, 2018
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.45 KB | None | 0 0
  1.    private Dialog alertDialog;
  2.  
  3.  
  4.    alertDialog = incomingCallDialog(VoiceActivity.this, activeCallInvite, answerCall(), cancelCall());
  5.    alertDialog.show();
  6.  
  7.  
  8.  
  9.  
  10.     public Dialog incomingCallDialog(final Context context, CallInvite callInvite, View.OnClickListener answerCall, View.OnClickListener cancelCall) {
  11.  
  12.         final Dialog dialog = new Dialog(context, android.R.style.Theme_Black_NoTitleBar_Fullscreen);
  13.         dialog.setContentView(R.layout.custom_dailog);
  14.  
  15.         TextView tv_from = (TextView) dialog.findViewById(R.id.tv_from);
  16.         FloatingActionButton accept = (FloatingActionButton) dialog.findViewById(R.id.btn_accept);
  17.         FloatingActionButton reject = (FloatingActionButton) dialog.findViewById(R.id.btn_reject);
  18.  
  19.         tv_from.setText("Your Custom Text");
  20.  
  21.         accept.setOnClickListener(answerCall);
  22.         reject.setOnClickListener(cancelCall);
  23.  
  24.         return dialog;
  25.     }
  26.  
  27.  
  28.  
  29.     private View.OnClickListener answerCall() {
  30.         return new View.OnClickListener() {
  31.  
  32.             @Override
  33.             public void onClick(View v) {
  34.                 alertDialog.dismiss();
  35.  
  36.                 // do your suff...
  37.             }
  38.         };
  39.     }
  40.  
  41.     private View.OnClickListener cancelCall() {
  42.         return new View.OnClickListener() {
  43.  
  44.             @Override
  45.             public void onClick(View v) {
  46.                 alertDialog.dismiss();
  47.  
  48.                 // do your suff...
  49.             }
  50.         };
  51.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement