直播app开发搭建,搜索框+含搜索历史记录

直播app开发搭建,搜索框+含搜索历史记录

1.撸个页面

 

activity_main.xml
<?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:orientation="vertical"
    tools:context="com.yhx.app.MainActivity">
    <RelativeLayout
        android:textColor="@color/gray"
        android:textSize="14sp"
        android:layout_marginTop="10dp"
        android:layout_width="match_parent"
        android:layout_height="45dp">
        <Button
            android:id="@+id/btn_serarch"
            android:layout_width="80dp"
            android:layout_height="match_parent"
            android:layout_alignParentRight="true"
            android:hint="搜索"/>
        <EditText
            android:id="@+id/et_search"
            android:hint="输入内容"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:layout_toLeftOf="@id/btn_serarch"/>
    </RelativeLayout>
    <RelativeLayout
        android:padding="10dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content">
        <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="历史记录"/>
        <TextView
            android:id="@+id/tv_deleteAll"
            android:layout_alignParentRight="true"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="删除历史记录"/>
    </RelativeLayout>
    <android.support.v7.widget.RecyclerView
        android:id="@+id/mRecyclerView"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_marginTop="10dp">
    </android.support.v7.widget.RecyclerView>
</LinearLayout>

​ 

2.使用Android自带的SQLiteOpenHelper来创建表数据

 

/**
 * Created by yi.huangxing on 17/12/13.类描述:
 */
public class RecordSQLiteOpenHelper  extends SQLiteOpenHelper{
    private static String name = "record.db";
    private static Integer version = 1;
    public RecordSQLiteOpenHelper(Context context) {
        super(context, name, null, version);
    }
    @Override
    public void onCreate(SQLiteDatabase db) {
        //打开数据库,建立了一个叫records的表,里面只有一列name来存储历史记录:
        db.execSQL("create table records(id integer primary key autoincrement,name varchar(200))");
    }
    @Override
    public void onUpgrade(SQLiteDatabase sqLiteDatabase, int i, int i1) {
    }
}

 

 以上就是直播app开发搭建,搜索框+含搜索历史记录, 更多内容欢迎关注之后的文章

 

posted @ 2023-06-29 14:06  云豹科技-苏凌霄  阅读(16)  评论(0编辑  收藏  举报