zoukankan      html  css  js  c++  java
  • android searchview 简单使用

    设置样式 drawable    bg_search/xml
    android:background="@drawable/bg_search"
    <shape xmlns:android="http://schemas.android.com/apk/res/android" >
        <!--这里是Linearlayout布局的背景颜色-->
        <solid android:color="@color/white" />
        <!--这里是设置边框线的粗细和颜色-->
        <stroke
            android:width="2dp"
            android:color="@color/el_warning" />
    
        <padding
            android:bottom="1dp"
            android:left="1dp"
            android:right="1dp"
            android:top="1dp" />
        <!--角的话,里边有参数可以单独设置-->
        <corners android:radius="20dp" />
    
    </shape>
    下面的处理不显示 icon 和 下划线  这里使用的时android
    设置左侧的icon 这里设置为不显示左侧icon  api22 以下无效果
    android:searchIcon="@null"    
    
    下面这两项处理不显示下划线   api21 以下无效果
    android:queryBackground="@null"
    android:submitBackground="@null"

     androidx 使用以下方式

    app:searchIcon="@null"
    app:queryBackground="@null"
    app:submitBackground="@null"

     简单使用

    search_view.requestFocus()
            search_view.setOnQueryTextListener(object : SearchView.OnQueryTextListener {
                override fun onQueryTextChange(newText: String?): Boolean {
                    Log.d(tag,"textChange=$newText")
                    return false
                }
    
                override fun onQueryTextSubmit(query: String?): Boolean {
                    Log.d(tag,"textSubmit=$query")
                    if(query.isNullOrBlank()){
                        Toast.makeText(this@CourseSearch,"请输入搜索条件",Toast.LENGTH_SHORT).show()
                        return false
                    }
    
                    if(query.length < 2 || query.length > 20){
                        Toast.makeText(this@CourseSearch,"搜索条件2-20位字符",Toast.LENGTH_SHORT).show()
                        return false
                    }
                    //查询处理代码
                    return false
                }
            })
  • 相关阅读:
    Zabbix配置文件详解之服务端zabbix_server
    Ansible批量远程管理Windows主机(部署与配置)
    ansible简要说明
    zabbix自动发现与自动注册
    Linux获取UUID
    python爬虫练习之批量下载zabbix文档
    cmake编译c++程序
    spring中PropertyPlaceholderConfigurer的运用---使用${property-name}取值
    spring中<bean>中parent标签的使用
    用静态工厂的方法实例化bean
  • 原文地址:https://www.cnblogs.com/rchao/p/11550147.html
Copyright © 2011-2022 走看看