How to create Custom Dialog in Sketchware
The code used:
final AlertDialog dialog2 = new AlertDialog.Builder(MainActivity.this).create();
View inflate = getLayoutInflater().inflate(R.layout.dialog, null);
dialog2.setView(inflate);
dialog2.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
final Button but1 = (Button) inflate.findViewById(R.id.button1);
final Button but2 = (Button) inflate.findViewById(R.id.button2);
final LinearLayout lin1 = (LinearLayout) inflate.findViewById(R.id.linear2);
_gd(lin1, "#FFFFFF", "#2196F3", 25);
_setCornerRadius(but1, 100, "#2196F3");
_setCornerRadius(but2, 100, "#1976D2");
but1.setOnClickListener(new OnClickListener() { public void onClick(View view) {
MainActivity.this.finish(); } });
but2.setOnClickListener(new OnClickListener() { public void onClick(View view) { dialog2.dismiss(); } });
dialog2.show();
A tutorial video is below:
final AlertDialog dialog2 = new AlertDialog.Builder(MainActivity.this).create();
View inflate = getLayoutInflater().inflate(R.layout.dialog, null);
dialog2.setView(inflate);
dialog2.getWindow().setBackgroundDrawableResource(android.R.color.transparent);
final Button but1 = (Button) inflate.findViewById(R.id.button1);
final Button but2 = (Button) inflate.findViewById(R.id.button2);
final LinearLayout lin1 = (LinearLayout) inflate.findViewById(R.id.linear2);
_gd(lin1, "#FFFFFF", "#2196F3", 25);
_setCornerRadius(but1, 100, "#2196F3");
_setCornerRadius(but2, 100, "#1976D2");
but1.setOnClickListener(new OnClickListener() { public void onClick(View view) {
MainActivity.this.finish(); } });
but2.setOnClickListener(new OnClickListener() { public void onClick(View view) { dialog2.dismiss(); } });
dialog2.show();
A tutorial video is below:
Comments
Post a Comment