为什么我的Andr​​oid微调显示在TextView中的单选按钮?我的、单选、按钮、oid

2023-09-07 22:07:11 作者:糜废

我有与动态管理的arrayadapter好手。当它得到显示,微调文本还显示单选按钮。我如何摆脱这种单选按钮?下拉箭头是所有strecthed和恶心的......这就是我的问题。注意:我说的不是出现在当我选择的下拉微调所显示的列表中的单选按钮

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? the drop down arrow is all strecthed and yucky... thats my problem. 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.

下面是相应的code片段......几点:

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

这code在窗口小部件的构造是微调的一个子类值是Object实例数组(小部件被创建时传递)有没有XML资源;所有部件都是动态创建想我需要为操纵的提示,我在构造函数中,并在onitemclicked事件监听器添加setPrompt(...)...这是没有效果的。

问:我失去了什么?在我看来,我的思念,这是造成的单选按钮,在微调的文本部分也显示微调的一些属性。

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.

- 喀嚓code -

-- 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");
    }
...

- 结束剪断code -

-- end snip code --

推荐答案

如果你想保持单选按钮,在微调,但不是在TextView中再做到这一点:

If you want to keep radio button in the spinner, but not in the textview then do this:

adapter = new ArrayAdapter<CharSequence>(activity, android.R.layout.simple_spinner_item);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);