最近项目中用到下拉列表,刚开始一头雾水,后来在网上找了一个Demo,自己修改了一下,现在把它分享出来,给大家参考,写的不好,多多关照!不过功能还是实现的了······先上图给大家看看效果!
效果图:
实现思路:
1.定义下拉控件布局(ListView及子控件布局)
2.自定义SpinerPopWindow类
3.定义填充数据的Adapter
一、定义控件布局:
1. activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#f2f2f2"
android:orientation="vertical"
android:padding="5dp" >
<LinearLayout
android:id="@+id/layout"
android:layout_width="match_parent"
android:layout_height="wrap_content"