zoukankan      html  css  js  c++  java
  • 安卓----Spinner

    <?xml version="1.0" encoding="utf-8"?>
    <FrameLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content">

    <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="2"
    android:text="按钮1"
    >
    </Button>
    <Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:text="按钮2"
    >
    </Button>

    在java中写

    Spinner sp =(Spinner)findViewById(R.id.sp);

    //设置资源列表项
    ArrayAdapter<CharSequence> adapter =
    ArrayAdapter.createFromResource(this, R.array.citys,
    android.R.layout.simple_spinner_dropdown_item);
    //设置下拉列表项
    sp.setAdapter(adapter);

    Spinner sp1 =(Spinner)findViewById(R.id.sp1);
    List<CharSequence> lists =new ArrayList<CharSequence>();
    lists.add("湖南");
    lists.add("上海");
    lists.add("湖北");
    ArrayAdapter<CharSequence> adapte =
    new ArrayAdapter<CharSequence>(this, android.R.layout.simple_spinner_item,lists);

    sp1.setAdapter(adapte);

  • 相关阅读:
    javaSE第二十四天
    javaSE第二十三天
    javaSE第二十二天
    javaSE第二十一天
    javaSE第二十天
    javaSE第十九天
    python020 Python3 OS 文件/目录方法
    python019 Python3 File(文件) 方法
    python018 Python3 输入和输出
    python017 Python3 模块
  • 原文地址:https://www.cnblogs.com/www123----/p/6875103.html
Copyright © 2011-2022 走看看