Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get input from a pop up window

//create inflater
final LayoutInflater inflater = (LayoutInflater) this
                .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
//create popupwindow
    PopupWindow pw=new PopupWindow(inflater.inflate(R.layout.menu, (ViewGroup)findViewById(R.layout.dictionarylist)));

        Button Menu = (Button) findViewById(R.id.Menu);
        Menu.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                pw.showAtLocation(v, Gravity.CENTER, 0, 0);
                pw.update(0, 0, 200, 250);
                pw.setOutsideTouchable(false);
            }
        });

What i want is to show the popup window when i click the button in the parent activity. The popup window have buttons when onclick the button it do some functions.

enter image description here

like image 477
Nas Avatar asked Nov 04 '12 08:11

Nas


1 Answers

You have to find the view of the button and then assign the listener to it like this:

View pview=inflater.inflate(R.layout.menu, (ViewGroup)findViewById(R.layout.dictionarylist));

Button Menu = (Button) pview.findViewById(R.id.Menu);

Menu.setOnClickListener(new Button.OnClickListener() {
            public void onClick(View v) {
                pw.showAtLocation(v, Gravity.CENTER, 0, 0);
                pw.update(0, 0, 200, 250);
                pw.setOutsideTouchable(false);
            }

Also initialize your inflator if you haven't already like this:

Inflator inflator = LayoutInflater.from(this);
like image 101
Anup Cowkur Avatar answered Oct 13 '22 00:10

Anup Cowkur