views:

65

answers:

1

i have a spinner with an arrayadapter that is dynamically managed. when it gets displayed, the spinner text also displays the radio button. how do i get rid of this radio button? NOTE: i'm not talking about the radio buttons that appear in the list that is displayed when i select the drop down on the spinner.

here is a pic of what it looks like: SIGH cannot upload image as i don't have 10 pts. so i've found a link: http://www.slashresources.com/android-gui-examples/ scroll down about 1/2 way and find the spinner example on that page. and my spinner looks like the spinner thats grayed out by the list. notice how the drop down arrow is all strecthed and yucky... thats my problem.

here are the appropriate code snippet... couple of points:

  • this code is in the constructor of widget which is a subclass of Spinner
  • value is an array of Object instances (passed when the widget gets created)
  • there are no XML resources; all widgets are dynamically created
  • thinking i need to "manipulate" the prompt, i added setPrompt(...) in the constructor and also in the onitemclicked event listener... this had no effect.

Q: what am i missing? seems to me i'm missing some attribute of the Spinner which is causing the radio button to also display in the text part of the spinner.

-- snip code --

public class ChoiceGroupImpl extends Spinner implements OnItemSelectedListener {
    public ChoiceGroupImpl(Activity activity, WidgetContainer container, Value widget, AttributeImpl attributes, Object[] value, int selected) {
...
        adapter = new ArrayAdapter<CharSequence>(activity, R.layout.simple_spinner_dropdown_item);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);

        for (int i = 0; i < value.length; i++)
            adapter.add(value[i].toString());
        if (attributes.isReadonly())
            setEnabled(false);
        setAdapter(adapter);
        setSelection(selected);
        setPrompt(adapter.getItem(selected));
        setOnItemSelectedListener(this);
...
}
    public void onItemSelected(AdapterView<?> parent, View view, int position, long id) {
        setPrompt(adapter.getItem(position));
        ((ToolkitImpl) Toolkit.getInstance()).hiddenCommand(container, "SelectionChanged");
    }
...

-- end snip code --

+1  A: 

use simple_spinner_item instead of simple_spinner_dropdown_item while creating your adapter

adapter = new ArrayAdapter<CharSequence>(activity, R.layout.simple_spinner_item);
franklins
Ah! that did it! seems simple enough no wonder i missed it! THX
Sheshadri Mantha
ok then.. accept the answer.
franklins