Click here to Skip to main content
15,893,564 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,
I am creating a popup window in Android Studio...
What I want is this.

1.)On signup click I am showing my popup window, now if user changes orientation of the screen, say while viewing this popup window he switches from portrait mode to landscape mode.. my popup window is gone...I know that while orientation is changed, activity is destroyed and recreated.. but I want to retain my popup window..

2)On choosing an option from popup window I am starting new activity. from my second activity when I go back to main activity using navigation of my app, my popup window is closed.... but when I am going back from device's back button... my popup window is still visible... I want to handle that too.

Any help....
Thank you.

What I have tried:

    ViewGroup customView;<br />
<br />
    //creating a popup window<br />
    public void showPopup(View view) {<br />
<br />
        LayoutInflater inflater = (LayoutInflater) getBaseContext().getSystemService(LAYOUT_INFLATER_SERVICE);<br />
        customView = (ViewGroup) inflater.inflate(R.layout.popup_layout, null);<br />
<br />
        popup = new PopupWindow(customView,<br />
                LinearLayout.LayoutParams.WRAP_CONTENT,<br />
                LinearLayout.LayoutParams.WRAP_CONTENT,<br />
                true);<br />
<br />
        popup.showAtLocation(constraintLayout, Gravity.CENTER, 0, 0);<br />
<br />
        rb1 = (RadioButton) customView.findViewById(R.id.rb_Individual);<br />
        rg = (RadioGroup) customView.findViewById(R.id.radioGroup);<br />
        rg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {<br />
            @Override<br />
            public void onCheckedChanged(RadioGroup group, @IdRes int checkedId) {<br />
//                      Toast.makeText(getBaseContext(),"You selected second radio button",Toast.LENGTH_LONG).show();<br />
<br />
                switch (checkedId) {<br />
                    case R.id.rb_Individual:<br />
                        Intent intent = new Intent(LoginActivity.this, Register.class);<br />
                        startActivity(intent);<br />
                        break;<br />
                    case R.id.rb_Club:<br />
                        Intent intentCl = new Intent(LoginActivity.this, Register.class);<br />
                        startActivity(intentCl);<br />
                        break;<br />
                    case R.id.rb_Organisation:<br />
                        Intent intentOrg = new Intent(LoginActivity.this, Register.class);<br />
                        startActivity(intentOrg);<br />
                        break;<br />
<br />
                }<br />
            }<br />
        });<br />
<br />
        customView.setOnClickListener(new OnClickListener() {<br />
            @Override<br />
            public void onClick(View v) {<br />
                if (rb1.isChecked()) {<br />
                }<br />
                popup.setClippingEnabled(false);<br />
            }<br />
        });<br />
<br />
<br />
    }<br />
Posted
Updated 30-Mar-17 0:05am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900