Hi all, I've been slugging away at trying to get an editable spinner component working. I've managed to get 95% of the way there but must confess I'm lost as to how the focus/layout system works within android - especially inside of this thing they call an AdapterView...
What I have working: * The spinner displays an EditText and I can type in it. * I can add a textChangedListener to the EditText and receive updates beautifully. * If I register an OnItemSelectedListener on the spinner, I can update the text field with the new selection & my textChangedListener will pick it up. What doesn't work: * My EditText doesn't scale up to the size of it's parent spinner. (Setting the layoutParams doesn't seem to help??? * When I change the selection via the spinner popup list, something changes so that my EditText no longer receives the orange ring around it when it has focus. (I still get the flashing cursor and can edit fine, it just loses the orange focus border) Would any kind soles have any advice to offer? Even any tips or websites on what the philosophy behind this onMeasure, onLayout philosophy is? I can't seem to find any books/sites that talk about GUI stuff that look any deeper than the xml. My spinner class so far is below. Cheers, Peter. class ApcSpinner extends Spinner implements SpinnerAdapter { protected EditText editText = null; LayoutInflater inflater; private final DataSetObservable observers = new DataSetObservable(); ArrayList<String> options = new ArrayList<String>(); public ApcSpinner(Context c) { super(c); for (int i=0; i < 10; i++) options.add("Record " + i); inflater = (LayoutInflater)c.getSystemService( Context.LAYOUT_INFLATER_SERVICE); editText = new EditText(c); editText.setHorizontalFadingEdgeEnabled(true); editText.setHorizontallyScrolling(true); setStyle(editText); if (style != null) { if (style.getBackgroundColour() != null) setBackgroundColor(style.getBackgroundColour()); } // Control ourselves... setAdapter(this); } public int getCount() { return options.size(); } public Object getItem(int position) { return options.get(position); } public long getItemId(int position) { return position; } public int getItemViewType(int position) { return 0; } public View getView(int position, View convertView, ViewGroup parent) { return editText; } public View getDropDownView(int position, View convertView, ViewGroup parent) { TextView textView; if (convertView != null) textView = (TextView)convertView; else textView = (TextView) inflater.inflate( android.R.layout.simple_spinner_dropdown_item, parent, false); textView.setText(getItem(position).toString()); setStyle(textView); return textView; } public int getViewTypeCount() { return 1; } public boolean hasStableIds() { return false; } public boolean isEmpty() { return options.size() == 0; } public void registerDataSetObserver(DataSetObserver observer) { observers.registerObserver(observer); } public void unregisterDataSetObserver(DataSetObserver observer) { observers.unregisterObserver(observer); } } --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---