Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android how to create popup window

I need to create a popup window with buttons and a button that will close the popup. I found some tutorials but I couldn't find out how to do the implementation.

What I want to do: Click an action button and the popup shows and when I click the the close button the popup window must close.

There were an onCreate method in the tuorials and I didn't understand how is it called.

Can somebody give an example of an popup implementation or a link to a good tutorial? Thank you!

like image 371
user3132352 Avatar asked Apr 12 '14 09:04

user3132352


1 Answers

private void showPopup(){
    Button btn_closepopup=(Button)layout.findViewById(R.id.btn_closePoppup);
    pwindo=new PopupWindow(layout,480,500,true);
    pwindo.showAtLocation(layout, Gravity.CENTER, 0, 40);
    chartContainer1.addView(mChart);
    btn_closepopup.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            // TODO Auto-generated method stub
            pwindo.dismiss();
        }
    });
}
like image 189
Zeeshan Khan Avatar answered Sep 19 '22 12:09

Zeeshan Khan