Hi poohtbear, I have no android source and I am using windows as development platform. As far as I read I am not able to get the source under windows?!
But based on your code I noticed, that the XML of my Spinner view and its drop down XML are different. The drop down XML has an additional RadioButton. If I use the same UI as I am using for my Spinner it works, but it does not look very well... It seems the onClick() of the spinner is never called. If I call performClick() when click on the RadioButton the drop down menu opens again. A dismiss is not called, also when the drop down is shown. Is there a way to use the default dropdown UI with radio buttons and fill it up with custom view elements on the left side? Thanks a lot! -Danny Schimke 2010/12/6 poohtbear <[email protected]> > That's a bit strange. > According to the code of spinner: > @Override > public boolean performClick() { > boolean handled = super.performClick(); > > if (!handled) { > handled = true; > Context context = getContext(); > > final DropDownAdapter adapter = new > DropDownAdapter(getAdapter()); > > AlertDialog.Builder builder = new > AlertDialog.Builder(context); > if (mPrompt != null) { > builder.setTitle(mPrompt); > } > mPopup = builder.setSingleChoiceItems(adapter, > getSelectedItemPosition(), this).show(); > } > > return handled; > } > > public void onClick(DialogInterface dialog, int which) { > setSelection(which); > dialog.dismiss(); > mPopup = null; > } > > if the AdapterView is not handling the performClick then a new alert > dialog that derives it's views from your adapter is created, and the > spinner is the onClick listener. > So when you click an item is should have dismissed the dialog. > > do you have the source code to put break points and debug it ? > On Dec 6, 11:13 am, Danny Schimke <[email protected]> > wrote: > > Hi, > > > > I googled a long time and still got no solution for my issue. I > customized > > my spinner view and the spinners dropdown menu. Within the spinner itself > I > > show a color representation and a simple text (I kicked some attributes > to > > save space in this post): > > > > spinner_color_item.xml > > > > > <?xml version="1.0" encoding="utf-8"?> > > > <LinearLayout xmlns:android=" > http://schemas.android.com/apk/res/android"> > > > <View android:id="@+id/vColorCode" /> > > > <TextView android:id="@+id/tvColorName" /> > > > </LinearLayout> > > > > My dropdown menu (one item element in the menu) looks like this: > > > > <?xml version="1.0" encoding="utf-8"?> > > > > > <LinearLayout xmlns:android=" > http://schemas.android.com/apk/res/android"> > > > <View android:id="@+id/vColorCode" /> > > > <TextView android:id="@+id/tvColorName" /> > > > <RadioButton android:id="@+id/rbChooseColor" /> > > > </LinearLayout> > > > > Everything looks fine, the spinner is shown as expected and the dropdown > > menu items look like I wanted. I am using a customized ArrayAdapter, for > > models that look like: > > > > public class ColorItem { > > > > > private String colorName; > > > private int colorValue; > > > private boolean selected; > > > public ColorItem() { > > > } > > > public ColorItem(String colorName, int colorValue) { > > > this.colorName = colorName; > > > this.colorValue = colorValue; > > > } > > > // some methods (getter and setter) > > > } > > > > The code within my onCreate method looks like: > > > > spiColor = (Spinner) findViewById(R.id.spiGroupColor); > > > > SpinnerColorAdapter colorAdapter = new SpinnerColorAdapter(this, > > > > > > > > > android.R.layout.simple_spinner_item, prepareColorItems()); > > > spiColor.setAdapter(colorAdapter); > > > OnItemSelectedListener l = new OnItemSelectedListener() { > > > @Override > > > public void onItemSelected(AdapterView<?> arg0, View view, int > > > position, long id) { > > > // never called. Why?! > > > if (spinnerInitialized) { > > > } > > > spinnerInitialized = true; > > > } > > > @Override > > > public void onNothingSelected(AdapterView<?> arg0) { > > > } > > > }; > > > spiColor.setOnItemSelectedListener(l); > > > > I overwrote the getDropDownView method of my custom adapter. The view is > > created successfully, how I defined in xml, but I want to close the > dropdown > > menu after selected one item, so I want to close it with clicking the > > radiobutton of one item. Set the selection works very well, but I have to > > exit the menu pressing escape in my emulator. > > > > Hope someone can help, I need a way to close the dropdown menu > > programatically. Does anybody have the same problem? > > > > Thanks a lot! > > -Danny Schimke > > -- > 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]<android-developers%[email protected]> > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- 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

