Widget - PopUp Window

//add a new CustomView myview.xml

//button1 onClick


View popupView = getLayoutInflater().inflate(R.layout.myview, null);
final PopupWindow popup = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);

TextView t1 = popupView.findViewById(R.id.textview3);
TextView t2 = popupView.findViewById(R.id.textview4);

t1.setOnClickListener(new OnClickListener() { public void onClick(View view) {
//YOUR CODE/BLOCKS HERE
popup.dismiss();
}});

t2.setOnClickListener(new OnClickListener() { public void onClick(View view) {
//YOUR CODES/BLOCKS HERE
popup.dismiss();
}});


popup.showAtLocation(popupView, Gravity.CENTER, 0, 0);

View popupView = getLayoutInflater().inflate(R.layout.myview, null);
final PopupWindow popup = new PopupWindow(popupView, ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT, true);

TextView t1 = popupView.findViewById(R.id.textview3);
TextView t2 = popupView.findViewById(R.id.textview4);

t1.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v){
//CODES TO BE EXECUTED
popup.dismiss();
}
});

t2.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick (View v){
//CODES TO BE EXECUTED
popup.dismiss();
}
});

popup.showAtLocation(popupView, Gravity.CENTER, 0, 0);

Komentar

Cara pembuatan Apps paling Populer

Create Stopwatch App in Android using Sketchware

TextInputLayout in Sketchware

How to find and​ highlight a word in a text field in Sketchware?

A Flash Light App in Sketchware

How to enable download in webview in Sketchware apps?

Intent - Open File By Type

Code for implementing Notifications in Sketchware

How to share an image from Drawable folder?

ActionBar back button

Animation Transtition Animation