直接在布局XML填充微调 [英] Populating spinner directly in the layout xml

查看:117
本文介绍了直接在布局XML填充微调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有可能来填充微调的选择权在布局XML? 此页面建议我应该使用ArrayAdapter?看来尴尬不能够做到这一点。

Is it possible to populate the options of a Spinner right in the layout xml? This page suggests I should use an ArrayAdapter? It seems awkward not being able to do it..

推荐答案

林不知道这一点,但给它一个镜头。

Im not sure about this, but give it a shot.

在你的strings.xml定义:

In your strings.xml define:

<string-array name="array_name">
<item>Array Item One</item>
<item>Array Item Two</item>
<item>Array Item Three</item>
</string-array>

在您的布局:

<Spinner 
        android:id="@+id/spinner"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:drawSelectorOnTop="true"
        android:entries="@array/array_name"
    />

我听说过这个设计者有时不工作,但编译罚款。

I've heard this sometimes doesnt work on the designer, but compiles fine.

这篇关于直接在布局XML填充微调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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