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?