I\'ve looked up a couple of posts for the same problem but can\'t seem to resolve my issue. I\'ve used spinners throughout my application and they are working fine. It\'s wh
The following is how the popup code is being called. I've declared the variable for the PopupWindow and ViewGroup so it can be used throughout the class
private PopupWindow pw_references;
private vg_references;
The code that calls the PopupWindow is called within an event handler for a button.
public void ibtn_references_Click(View view) {
...
// 1st section of code in the original post
}
This button is inside a linearlayout (seperate layout file) that is then included within a framelayout on the current screen. Included something like the following.
<FrameLayout
android:id="@+id/lay_rowButtons"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/backgroud_border"
android:padding="10dp" >
<include android:id="@+id/buttons" layout="@layout/buttons" />
</FrameLayout>
Can you try by replacing following line:
pw_references = new PopupWindow(vg_references,
this.getWindowManager().getDefaultDisplay().getWidth()/100 * 75,
this.getWindowManager().getDefaultDisplay().getHeight()/100 * 50,
true);
with
pw_references = new PopupWindow(this);
pw_references.setWidth(this.getWindowManager().getDefaultDisplay().getWidth()/100 * 75);
pw_references.setHeight(this.getWindowManager().getDefaultDisplay().getHeight()/100 * 50);
pw_references.setContentView(vg_references);
where this
refer to the current activity
reference. Just to see if this make any difference...
The only way I could get this to work was to use a Dialog rather than a PopupWindow. It works fine that way
I had this problem in my work, and wasted about 2 days trying to find a solution to it. But, I didn't find a solution from the web.
The solution was to specify the Spinner
mode to be dialog
.
from XML layout:
android:spinnerMode="dialog"
or from java code:
Spinner(Context context, int mode)
I hope my answer was helpful