依赖:
1.添加依赖

①.在项目的 build.gradle 文件中添加

allprojects {repositories {...maven { url 'https://jitpack.io' }}}

②.在 module 的 build.gradle 文件中添加依赖

dependencies {implementation 'com.github.LRH1993:AutoFlowLayout:1.0.5'
}
public class MainActivity extends AppCompatActivity implements View.OnClickListener {private MySearch mMysearch;private ImageView mMainRight;private AutoFlowLayout mMainFlow;/*** 清空历史搜索*/private Button mMainButton;private LayoutInflater layoutInflater;private List<String> list;private String s;private View view;private TextView flow_text;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);initView();
//      流式布局数据list = new ArrayList<>();}//初始化控件private void initView() {mMysearch = (MySearch) findViewById(R.id.Mysearch);mMainRight = (ImageView) findViewById(R.id.Main_right);mMainRight.setOnClickListener(this);mMainFlow = (AutoFlowLayout) findViewById(R.id.Main_flow);layoutInflater = LayoutInflater.from(this);mMainButton = (Button) findViewById(R.id.main_button);mMainButton.setOnClickListener(this);}@Overridepublic void onClick(View v) {switch (v.getId()) {default:break;case R.id.Main_right:
//取得输入框内容s = mMysearch.getEdit();Log.d("MainActivity-----", s);
//                加入到搜索框集合list.add(s);Toast.makeText(this, "mData.length:" + list.size(), Toast.LENGTH_SHORT).show();
//             初始化流失布局条目布局view = layoutInflater.inflate(R.layout.layout_flow, null);flow_text = view.findViewById(R.id.flow_text);
//                给每个条目赋值输入的历史记录for (int i = 0; i < list.size(); i++) {flow_text.setText(list.get(i));}
//                加入流式布局mMainFlow.addView(view);break;case R.id.main_button:
//                清空历史list.clear();Log.d("MainActivity", "list.size():" + list.size());mMainFlow.removeAllViews();break;}}
}

自定义搜索控件

public class MySearch extends LinearLayout{private EditText mysearch_edi;public MySearch(Context context) {this(context,null);}public MySearch(Context context, @Nullable AttributeSet attrs) {this(context, attrs,0);}public MySearch(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {super(context, attrs, defStyleAttr);View view = View.inflate(context, R.layout.layout_mysearch, this);mysearch_edi = view.findViewById(R.id.mysearch_edit);}//    获取输入框内容public String getEdit(){return mysearch_edi.getText().toString();}}

更新的方法

//  mAtflow 流式控件mAtflow.setAdapter(new FlowAdapter(list_flow) {@Overridepublic View getView(int i) {
//      子条目布局view_atfl = View.inflate(HistoryActivity.this, R.layout.flow_layout, null);TextView text = view_atfl.findViewById(R.id.flw_text);//               设置数据text.setText(list_flow.get(i));return view_atfl;}});

流式布局清空历史搜索相关推荐

  1. 自定义 FlowLayout流式布局搜索框 加 GreenDao存取搜索记录,使用RecyclerView展示

    输入框布局的shape <?xml version="1.0" encoding="utf-8"?> <shape xmlns:android ...

  2. android 搜索历史流布局,FlowLayout流式布局实现搜索清空历史记录

    本文实例为大家分享了FlowLayout实现搜索清空历史记录的具体代码,供大家参考,具体内容如下 效果图:点击搜索框将搜索的历史在流式布局中展示出来,清空历史记录就会将历史清空,每次搜索后都存入sp中 ...

  3. FlowLayout流式布局实现搜索清空历史记录

    效果图:点击搜索框将搜索的历史在流式布局中展示出来,清空历史记录就会将历史清空,每次搜索后都存入sp中,每次进入页面都先判断sp里是否有值并展示 首先需要导入一个module,下载地址:https:/ ...

  4. Android第三方流式布局FlowLayout简单实用(搜索历史记录)

    效果图: 导入大Model下: maven { url 'https://jitpack.io' } builde.gradle依赖: implementation 'com.github.LRH19 ...

  5. 仿唯品会/京东/淘宝搜索流式布局的隐藏与展示

    1. 项目需求: 如下,如果没有向下箭头(显示/隐藏剩余搜索词条)的话,采用flexbox-layout+Recycleview+FlexboxLayoutManager 可以实现流式布局. 加了这个 ...

  6. 手写一个淘宝、京东的搜索流式布局FlowLayout

    目录 一些叨叨 继承ViewGrop 实现自定义控件 重写构造器 提供对外接口 测量 摆放 使用方法 完整代码 一些叨叨 市面上所有的app只要有搜索功能,几乎都离不开流式布局,像淘宝.京东.小红书等 ...

  7. android搜索热词(热门标签)流式布局的实现

    先看下效果图 1.流式布局实现 继承ViewGroup,重写onMeasure,onLayout方法.代码如下: package com.example.lin.flowlayoutdemo;impo ...

  8. Flutter文本标签TextTagWidget,搜索记录流式布局显示文本标签

    题记 -- 执剑天涯,从你的点滴积累开始,所及之处,必精益求精,即是折腾每一天. 重要消息 网易云[玩转大前端]配套课程 EDU配套 教程 Flutter开发的点滴积累系列文章 1 添加依赖 flut ...

  9. Android 流式布局

    Android 流式布局 首先目标 最近Android流式布局很火爆,首先我们可以把这一标签页的整体看成一个容器,然后容器内有许多小控件(TextView,Button,ImageView等),再来这 ...

最新文章

  1. APK Expansion Files / Obb 接入介绍
  2. 【SPOJ-QTREE】树链剖分
  3. 利用mochiweb让服务端主动推送数据至前端页面
  4. 计算机组成要素二:布尔运算:ALU算术运算器
  5. C#LeetCode刷题之#56-合并区间(Merge Intervals)
  6. Git成立14周年快乐:您对Git钟爱什么?
  7. ZedGraph设置辅助线
  8. Unity3D游戏开发之GUI
  9. 学python前端需要哪些基础知识_简析前端学习python3的基础
  10. C语言 — 数据类型,基本整型所占字节数
  11. 组建团队和调整团队结构
  12. Java读写gif格式图片,解决ImageIO读取gif文件只读取第一帧的问题(read and write gif format pictures in Java)
  13. linux系统防火墙关闭22端口,Linux系统防火墙关闭及端口开放
  14. 2013华为工作之电信客服上线
  15. 有梦想,就去追,不犹豫,不后悔
  16. 【CXY】JAVA基础 之 Collection
  17. 机电一体化c语言程序设计,高职机电一体化C语言程序设计研究
  18. 翻译 Albert Julian Mayer 关于虚拟纹理的论文(2. 相关工作)
  19. Tuxera NTFS for Mac2020注册机
  20. 泰拉瑞亚加mod之后如何搭建服务器进行联机

热门文章

  1. 基于java+jsp+ssm餐饮管理系统-计算机毕业设计
  2. 【Jvm内存】EclipseMemoryAnalyzer分析内存
  3. 在编译robot_pose_ekf时报错no module orocos-bfl
  4. 钉钉OA审批事件回调遇坑梳理-如何注册多个事件回调
  5. 这也行?动手用Python做一个酒精检测仪,数据还能直接上云
  6. ng bind html 无效,ng-bind-html中 自定义的指令 不生效!
  7. 【数据结构】【顺序表】 SqList *L与SqList*L的区别
  8. phpstorm 2017激活码(亲测可用)
  9. 升级最新版本Android Studio Arctic Fox 遇到的问题
  10. 浅谈OA管理系统的一些要点