通过资源文件配置Android下拉列表…
2013-12-30 20:36
323 查看
1、首先找到我们res文件夹下边的layout下边的xml文件
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity"
>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10px"
此部分的值在values文件夹当中string.xml
android:text="@string/city" />
<Spinner
android:id="@+id/myspinner"
android:prompt="@string/city"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40px"
下边代表的是我们values文件夹当中的city.xml当中的数值
android:entries="@array/citylist"/>
</RelativeLayout>
2、找到我们values文件夹当中的string.xml
<?xml
version="1.0" encoding="utf-8"?>
<resources>
<string
name="app_name">SpinnerDemo</string>
<string
name="hello_world">Hello
world!</string>
<string
name="menu_settings">Settings</string>
<string
name="city">请选择您所在的城市</string>
</resources>
3、找到vaule文件夹下边的city.xml
<?xml
version="1.0" encoding="utf-8"?>
<resources>
<string-array
name="citylist">
<item>北京</item>
<item>上海</item>
<item>南京</item>
<item>深圳</item>
</string-array>
</resources>
相关文章推荐
- Android - Selector通过资源文件配置UI属性大全
- android 上下文菜单(长按)通过配置文件生成
- android反编译之获得res下的xml配置文件及图片等资源
- 通过Android-sharedUserId访问不同apk的资源文件(资源和数据库)
- Android 反编译得到图片、XML配置、语言资源等文件
- android 子菜单 通过配置文件生成
- Android apk反编译图解(得到程序的java源代码,图片、XML配置、语言资源等文件)
- Android基于配置文件的测试模式(不修改代码通过配置文件来打开和关闭测试模式)
- Android如何给不同配置机器引入对应的资源文件
- Android中通过xml资源文件定义数组
- Android通过LIstView显示文件列表
- Android中通过xml资源文件定义数组
- 通过命令行实现Android工程资源文件到apk的流程
- 通过类加载器管理资源和配置文件
- 通过字段名称动态获取资源的id(将Android工程做成jar包和资源文件)
- android应用面试宝典(下);用自定义组件控制循环组件使用bug还添加标志显示答案标志位;通过包名读取配置文件AndroidManifest.xml
- Android通过LIstView显示文件列表
- Android apk反编译图解(得到程序的java源代码,图片、XML配置、语言资源等文件)
- android通过拼写字符串获取资源文件
- Android studio 通过build.gradle 配置打包签名文件,生成 xxx.apk