I am still unable to capture the OnItemClick event from my GridView that is in the PopupWindow. Can anybody help me with this?
On Dec 4, 12:48 am, k_day <[email protected]> wrote: > I ended up finding the problem. I was using the ImageAdapter code > form the Hello, Gallery example. That contained a line of code > referencing a Gallary: > > imageView.setLayoutParams(new Gallery.LayoutParams(150, 120)); > > When used with a GridView, this obviously causes a class cast > exception. > > Now that I have my GridView displaying properly in a popupwindow, I am > having trouble capturing the OnItemClick event. Below is my code. > OnItemClick is never being called when I make a selection in my > gridview in the popupwindow. Any ideas? > > final GridView gView = (GridView) grid_layout.findViewById > (R.id.gridview_layout); > gView.setWillNotDraw(false); > gView.setFocusableInTouchMode(true); > gView.setClickable(true); > gView.setAdapter(new ImageAdapter(this)); > > final PopupWindow soundSelectorWindow = new PopupWindow(this); > soundSelectorWindow.setContentView(grid_layout); > soundSelectorWindow.setBackgroundDrawable(new BitmapDrawable()); > soundSelectorWindow.setOutsideTouchable(false); > soundSelectorWindow.setTouchable(true); > > gView.setOnItemClickListener(new OnItemClickListener() > { > public void onItemClick(AdapterView parent, View v, int position, > long id) > { > //Never gets here. > soundSelectorWindow.dismiss(); > } > }); > > On Nov 14, 3:43 pm, k_day <[email protected]> wrote: > > > I did notice that if I remove > > > popupview.setAdapter(new ImageAdapter(this)); > > > I no longer throw the exception. Am I using the Adapter wrong? Any > > help would really be appreciated. > > > On Nov 10, 7:29 pm, k_day <[email protected]> wrote: > > > > I tried to post on > > > >http://groups.google.com/group/android-developers/browse_thread/threa... > > > > but it appears the discussion is locked (no reply button) for some > > > reason. > > > > I am having a similar 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)); > > > > I 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? > > > > Thanks. > > > > -k_day -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

