PopupWindow with GridView - Trouble with inflating view

Posted by k_day on Stack Overflow See other posts from Stack Overflow or by k_day
Published on 2009-11-11T23:11:15Z Indexed on 2010/03/27 8:03 UTC
Read the original article Hit count: 481

Filed under:
|
|

I am having an issue while trying to use a GridView in a PopupWindow. On my Activity's onCreate method, I am inflating a gridview from xml as follows:

LayoutInflater inflater = (LayoutInflater)this.getSystemService (Context.LAYOUT_INFLATER_SERVICE); final GridView popupview = (GridView) inflater.inflate (R.layout.gridviewpopup, null, false); popupview.setAdapter(new ImageAdapter(this));

would like this GridView to popup on a button click. Also inside of my activity's onCreate, I have:

final Button addButton = (Button) findViewById(R.id.add); addButton.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
PopupWindow mwindow = new PopupWindow(popupview, 100, 100); mwindow.showAtLocation(findViewById(R.id.main), Gravity.CENTER, 100, 100); mwindow.setFocusable(true);
}
});

On button click, I am throwing a ClassCastException from GridView.onMeasure(int, int).

Can anyone please explain to me what I am doing wrong?

© Stack Overflow or respective owner

Related posts about android

Related posts about gridview