为什么我的Andr​​oid微调显示在TextView中的单选按钮? [英] why does my android spinner display the radio button in the textview?

查看:120
本文介绍了为什么我的Andr​​oid微调显示在TextView中的单选按钮?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有与动态管理的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);

这篇关于为什么我的Andr​​oid微调显示在TextView中的单选按钮?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆