How to create a rounded dialog in Sketchware - sketchware code



To create A dialog with rounded corners follow given steps



1. First create a custom view with ID custom.xml and design the layout of the dialog in this custom view.


2. In onCreate Add an addSourceDirectly block and enter the following code. 



final AlertDialog dialog = new AlertDialog.Builder(MainpageActivity.this).create();
//MainPageActivity.this is your activity
LayoutInflater inflater = getLayoutInflater();

View convertView = (View) inflater.inflate(R.layout.custom, null);
//Custom is your custom view
dialog.setView(convertView);
TextView textview4 = (TextView)
convertView.findViewById(R.id.textview4);
textview4.setText("your text here!");
Button button1 = (Button) convertView.findViewById(R.id.button1);
button1.setOnClickListener(new View.OnClickListener(){
    public void onClick(View v){
dialog.dismiss();
        
       
    }
});

dialog.show();





2 Comments

  1. How to Close (dismiss) the Dialog on an another Method?
    For example: Show Dialog in on create and dismiss it on Network Response (componement requests Network on Response) ? It says Dialog can not be resolved to a variable...

    ReplyDelete
Previous Post Next Post