wheel自定义控件,实现城市三级联动,时间选择的功能简单使用

                对于android初学者,最烦的就是学习自定义控件。原生的控件不是丑就是无法满足需求,不得以我们只好自己重写控件的方法,下面我就为大家介绍一下某大神自定义的wheel控件Android滚轮控件,基于ListView实现,可以自定义样式。,此控件可以实现城市选择的多级联动,时间选择等多种功能,具体自己DIY呗!


效果图:

      


首先看一下布局main_layout

        android:orientation="vertical">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">

            <com.wx.wheelview.widget.WheelView
                android:id="@+id/main_wheelview"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:layout_weight="1"/>

            <com.wx.wheelview.widget.WheelView
                android:id="@+id/sub_wheelview"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:layout_weight="1"/>

            <com.wx.wheelview.widget.WheelView
                android:id="@+id/child_wheelview"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_margin="10dp"
                android:layout_weight="1"/>
        </LinearLayout>

    接着看MainActivity

/**
     * 联动WheelView
     */
    private void initWheel1() {
        mainWheelView = (WheelView) findViewById(R.id.main_wheelview);
        mainWheelView.setWheelAdapter(new ArrayWheelAdapter(this));  //设置滚轮数据适配器s
        mainWheelView.setSkin(WheelView.Skin.Holo);  //设置背景颜色
        mainWheelView.setWheelData(createMainDatas()); //设置滚轮数据
  
  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值