背景:
阅读新闻
Android 之 Spinner 下拉菜单实现级联
[日期:2013-03-13] 来源:Linux社区 作者:jenminzhang [字体:]
Android 之 Spinner 下拉菜单实现级联效果图如下:
默认第一次加载
选择原始队列:
级联效果图:
关键代码给下拉列表选中事件监听绑定Id :
int pos = firsthand_dlbh_pinner.getSelectedItemPosition();
firsthand_pdbh_adapter = new ArrayAdapter<String>(context,
android.R.layout.simple_spinner_item, queu_info[pos]);
firsthand_pdbh_spinner.setAdapter(firsthand_pdbh_adapter);
完整代码:
布局文件代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/firsthand_dlbh"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="60sp"
android:layout_marginTop="20sp" >
</TextView>
<Spinner
android:id="@+id/firsthand_dlbh_pinner"
android:layout_width="200sp"
android:layout_height="wrap_content"
android:layout_marginLeft="60sp"
android:layout_marginTop="20sp" >
</Spinner>
<TextView
android:id="@+id/firsthand_pdbh"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="60sp"
android:layout_marginTop="20sp" >
</TextView>
<Spinner
android:id="@+id/firsthand_pdbh_pinner"
android:layout_width="200sp"
android:layout_height="wrap_content"
android:layout_marginLeft="60sp"
android:layout_marginTop="20sp" >
</Spinner>
<TextView
android:id="@+id/target_dlbh"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="60sp"
android:layout_marginTop="20sp" >
</TextView>
<Spinner
android:id="@+id/target_dlbh_spinner"
android:layout_width="200sp"
android:layout_height="wrap_content"
android:layout_marginLeft="60sp"
android:layout_marginTop="20sp" >
</Spinner>
<Button
android:id="@+id/diff_manage_operation"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="100sp"
android:layout_marginTop="20sp"
android:text="执行调度"
android:textSize="18sp" >
</Button>
</LinearLayout>