上效果图:
直接上传自定义LAYOUT /xml 文件代码;完善之前发布的《自定义 既可输入文字又可选择的 控件ComBox》
1.引用自定义控件:com.zxf.testmycombox 包名 ;ComboBox 类名 ;
注意:必须写完整,才可以引用
<com.zxf.testmycombox.ComboBox
android:id="@+id/main_combox"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@id/main_et"
/>
2.test.xml -具体自定义的xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="#EFe4EF">
<EditText
android:id="@+id/comboEditText"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="40dp"
android:layout_marginLeft="5dp"
android:layout_marginTop="4dp"
android:hint="请输入" >
</EditText>
<Button
android:layout_gravity="center_vertical"
android:background="@drawable/icon_dropdown"
android:layout_width="50dp"
android:layout_height="50dp"
android:id="@+id/comboButton">
</Button>
</LinearLayout>
3.comboBox_listview.xml ;
点击 按钮以后,弹出的PopWindow 引用的ListView 布局
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<ListView
android:id="@+id/id_listview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginBottom="48dp"
android:cacheColorHint="#00000000"
android:dividerHeight="1dp"
android:fadingEdge="none"
android:background="#FFFFFF"/>
</LinearLayout>
4.comboBox_item.xml
该文件是listView 的item 样式
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#ffff00"
android:gravity="center_vertical" >
<TextView
android:id="@+id/id_txt"
android:textColor="#444444"
android:layout_marginLeft="10dp"
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="35dp"/>
</RelativeLayout>
6 .附带 一张,按钮样式
.