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

posted on 2017-05-18 21:04  星星&之火  阅读(167)  评论(0编辑  收藏  举报