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);

  • 相关阅读:
    代码整洁之道
    PHP并发IO编程之路
    U盘启动盘的制作--用U盘硬装Windows系统、或是重装Windows系统
    Navicat for MySQL11--使用经验
    Eclipse字体颜色的设置方法
    5.5树和森林
    5.2二叉树
    3.3队列
    3.1栈
    2.3线性表的链式存储结构
  • 原文地址:https://www.cnblogs.com/www123----/p/6875103.html
Copyright © 2011-2022 走看看