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

  • 相关阅读:
    HTML简单的用户资料
    PhP CSS常用选择器
    PHPCSS样式表
    PHP第四日随笔
    一些记不住的东西
    错误记录
    关于空想X
    DSA 祖玛
    洛谷 P1194 买礼物
    Git笔记
  • 原文地址:https://www.cnblogs.com/wojiatingting/p/6875592.html
Copyright © 2011-2022 走看看