实例代码展示
利用SQLite做出student数据库,使用RecyclerView
可与之前的文章https://blog.csdn.net/easonfff/article/details/79743154
ContentProvider&ContentResolver结合并用
布局代码
activity_main
<RelativeLayout 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"
tools:context="com.homework.activity.sqlrecyclerview.MainActivity">
<LinearLayout
android:id="@+id/header_ll"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal">
<EditText
android:id="@+id/add_et"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1" />
<Button
android:id="@+id/add_btn"
android:text="添加"
android:layout_width="80dp"
android:layout_height="match_parent" />
</LinearLayout>
<LinearLayout
android:layout_alignParentBottom="true"
android:id="@+id/bottom_ll"
android:layout_width="match_parent"
android:layout_height="60dp"
android:orientation="horizontal">
<Button
android:id="@+id/random_btn"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:text="随机显示"/>
<Button
android:id="@+id/all_btn"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="match_parent"
android:text="全部列出"/>
</LinearLayout>
<android.support.v7.widget.RecyclerView
android:layout_below="@id/header_ll"</