历史记录 and 搜索记录 流式布局

//流式布局  导入依赖
implementation 'com.github.1002326270xc:LayoutManager-FlowLayout:v1.6'

//整个布局

 <?xml version="1.0" encoding="utf-8"?>
 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/commonBackground"
android:fitsSystemWindows="false"
android:orientation="vertical">

<RelativeLayout
    android:layout_width="match_parent"
    android:layout_height="@dimen/dp_35"
    android:layout_marginTop="@dimen/dp_52">

    <RelativeLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginLeft="@dimen/dp_15"
        android:layout_marginRight="@dimen/dp_60"
        android:background="@drawable/shape_stroke_orange_8"
        android:paddingLeft="@dimen/dp_18">

        <ImageView
            android:id="@+id/iv_search"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerVertical="true"
            android:background="@mipmap/ic_home_search" />

        <com.zhenpin.kxx.app.view.ClearTextEditText
            android:id="@+id/menu_edit"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_gravity="center"
            android:layout_marginLeft="@dimen/dp_8"
            android:layout_marginRight="@dimen/dp_8"
            android:layout_toRightOf="@id/iv_search"
            android:layout_weight="1"
            android:background="@null"
            android:gravity="center_vertical"
            android:hint="请输入搜索商品"
            android:singleLine="true"
            android:textColor="@color/blank"
            android:textColorHint="#999999"
            android:textCursorDrawable="@drawable/edittext_shape_two"
            android:textSize="@dimen/sp_14" />
    </RelativeLayout>

    <TextView
        android:id="@+id/tv_cantuan"
        android:layout_width="@dimen/dp_60"
        android:layout_height="match_parent"
        android:layout_alignParentRight="true"
        android:layout_centerVertical="true"
        android:gravity="center"
        android:text="取消"
        android:textColor="#ff666666"
        android:textSize="14sp" />
</RelativeLayout>

<LinearLayout
    android:id="@+id/ll_search"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="@dimen/dp_9"
    android:background="@drawable/bg_radius"
    android:orientation="vertical">

    <LinearLayout
        android:id="@+id/ll_search_s"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical">

        <RelativeLayout
            android:visibility="visible"
            android:id="@+id/ls_text"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">

            <TextView

                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/dp_16"
                android:layout_marginTop="@dimen/dp_15"
                android:text="历史记录"
                android:textColor="#ff000000"
                android:textSize="16sp" />

            <ImageView
                android:id="@+id/delete_ls"
                android:layout_width="17dp"
                android:layout_height="17dp"
                android:layout_alignParentRight="true"
                android:layout_marginTop="@dimen/dp_16"
                android:layout_marginRight="@dimen/dp_20"
                android:src="@mipmap/delete" />
        </RelativeLayout>

        <android.support.v7.widget.RecyclerView
            android:id="@+id/histotyRecycler"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="@dimen/dp_10"
            android:layout_marginTop="@dimen/dp_10"
            android:layout_marginRight="@dimen/dp_10" />

        <LinearLayout
            android:id="@+id/ll_rm_s"
            android:visibility="visible"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical">

            <TextView
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/dp_16"
                android:layout_marginTop="@dimen/dp_15"
                android:text="热门搜索"
                android:textColor="#ff000000"
                android:textSize="16sp" />
            <android.support.v7.widget.RecyclerView
                android:id="@+id/rm_Recycler"
                android:layout_width="match_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="@dimen/dp_10"
                android:layout_marginTop="@dimen/dp_10"
                android:layout_marginRight="@dimen/dp_10" />
        </LinearLayout>

    </LinearLayout>
</LinearLayout>
</LinearLayout>

activity
//adapter主要设置

        FlowLayoutManager flowLayoutManager = new FlowLayoutManager();
        histotyRecycler.setLayoutManager(flowLayoutManager);
        histotyRecycler.addItemDecoration(new SpaceItemDecoration(dp2px(0)));
        adapter = new HistorySearchAdapter(SearchhistoryActivity.this, searchBeans);
        histotyRecycler.setAdapter(adapter);

//上边EditText 点击 键盘控制

        menuEdit.setOnKeyListener(new View.OnKeyListener() {
        @Override
        public boolean onKey(View v, int keyCode, KeyEvent event) {
            //是否是回车键
            if (keyCode == KeyEvent.KEYCODE_ENTER && (event.getAction() == KeyEvent.ACTION_DOWN || event.getAction() == KeyEvent.KEYCODE_SEARCH)) {
                //请求一下保存历史记录
                if (tags == 1) {
                    key = menuEdit.getText().toString();
                    JPushUtils.onEvent(getApplicationContext(), "Search_submit", "点击搜索");
                    Intent intent = new Intent(SearchhistoryActivity.this, SearchActivity.class);
                    intent.putExtra("input_title", key);
                    intent.putExtra("number", number);
                    intent.putExtra("tag",tags);
                    intent.putExtra("merchantUuid",merchantUuid);
                    startActivity(intent);
                }else {
                    key = menuEdit.getText().toString();
                    mPresenter.getProductCollecList("", "", "", "", key);
                }

            }

            return false;
        }
    });
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值