自定义 既可输入文字又可选择的 控件ComBox—2

上效果图:



直接上传自定义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 .附带 一张,按钮样式 

 .


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值