• SQLite实现的学生管理系统


    SQLite数据库

    案例资源所在地址:

    https://download.csdn.net/download/weixin_41957626/87150608?spm=1001.2014.3001.5503

    1.简介

    1.1引入

    1.前面学习的文件存储和SharedPreference存储的方式只能存储一些小型的数据但是对于复杂关系以及复杂数据结构的数据仅仅靠文件存储是不能进行实现的。

    1.2SQLite简介

    1.该类数据库是关系型的数据库实现的功能是MyuSQL数据库是十分相似的,但SQLite没有服务器进程所以把只能是单机版的,不能运行在服务端上。但是优点是小,非常的适合在移动设备上进行使用。除了服务器进程其余的和MySQL是四类的。SQL语句的支持的也是几乎是全部兼容的,仅仅是一小部分的语句是不同的。

    2.常见的sql语句

    • 查询:select 字段 from 表 where 条件 group by 分组 havintg 筛选

    • 插入:insert into 表 字段 values 值

    • 更新:update 表 set 字段=新值 (注意只能出现一个set,我老是写多个,要注意where条件)

    • 删除:delete from 表 where 条件

    1.3案例学生信息管理系统

    最后会在增删改查中进行实现。

    2.SQLiteHelper

    2.1简介

    使用SQLiteHelper的作用,预先创建数据库表而不是手动的去创建。

    可用于数据库的创建和数据库表的更新。

    1.SQLiteHelper:是一个抽象的类,需要去继承,才能用的,需要重写构造方法和里面创建数据库和更新数据库的方法。这个类其实就是jdbc中Connection和Preparement的结合体。

    2.Cursor:游标。类似JDBC中的result集合,是用来遍历结果集的。需要使用next指向下一条记录。

    2.2创建过程

    数据库存放的地方,data/data/项目名/database包下

    1.自定义类继承SQLiteHelper重写其中的方法。

    2.主要是重写里面的oncreate方法。

    3.需要重写里面的构造方法,一般来说需要将游标设置为null,第一个参数是上下文,第二个是数据库的名称,第三个是游标,第四个是版本号。

    2.3打开数据库

    1.打开数据库的方法?

    以下两种方式得到的都是被SQLiteDatabase对象

    • 只读方式:getReadableDatabase,如果打开的数据库满了,此时只能读不能写

    • 可读可写的方式::getWritableDatabase,如果打开的数据库满了,此时只能读不能写,但是还是被会报错的。

    注意打开的数据库需要进行关闭操作!调用close方法就可以。

    2.4实例

    实例:创建一个数据库帮助类

    • 重写了一个构造方法

    • 重写了oncreate方法,进行了数据库的创建

    • 重写了onupgrade方法,进行数据库表的更新,多加了一个新的字段

    1. //===数据库帮助类
    2. public class MySQLitehelper extends SQLiteOpenHelper {
    3. // 构造方法
    4. public MySQLitehelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
    5. super(context, name, factory, version);
    6. }
    7. // 创建一个不需要游标的构造方法
    8. public MySQLitehelper(@Nullable Context context, @Nullable String name, int version) {
    9. super(context, name, null, version);
    10. }
    11. // 创建数据库表的方法
    12. @Override
    13. public void onCreate(SQLiteDatabase db) {
    14. //此方法再创建此类的对象后进行回调,编写一条可以执行的sql语句
    15. db.execSQL("create table student (id interger primary key autoincrement,name varchar(20),age varchar(10))");
    16. }
    17. // 更新数据库表表的方法
    18. @Override
    19. public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    20. //当版本号发生更新的时候进行回调
    21. //一般是田家炳新的数据库字段的时候进行回调
    22. db.execSQL("alter table student add sex varchar(10)");
    23. }
    24. }
    25. //===数据库帮助类
    26. public class MySQLitehelper extends SQLiteOpenHelper {
    27. // 构造方法
    28. public MySQLitehelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
    29. super(context, name, factory, version);
    30. }
    31. // 创建一个不需要游标的构造方法
    32. public MySQLitehelper(@Nullable Context context, @Nullable String name, int version) {
    33. super(context, name, null, version);
    34. }
    35. // 创建数据库表的方法
    36. @Override
    37. public void onCreate(SQLiteDatabase db) {
    38. //此方法再创建此类的对象后进行回调,编写一条可以执行的sql语句
    39. db.execSQL("create table student (id interger primary key autoincrement,name varchar(20),age varchar(10))");
    40. }
    41. // 更新数据库表表的方法
    42. @Override
    43. public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    44. //当版本号发生更新的时候进行回调
    45. //一般是田家炳新的数据库字段的时候进行回调
    46. db.execSQL("alter table student add sex varchar(10)");
    47. }
    48. }

    3.SQLiteDatabase

    该类的作用就是用来进行对数据库的增删改查操作的

    3.1创建过程

    1.创建的过程

    • 创建一个自定义的helper对象

    • 获取一个可读或者是可写的SQLiteDatabase对象

    • 通过第二步获取的对象进行增删改查的操作

    3.2常见的方法

    就是CRUD操作

    1.create

    2.query

    3.update

    4.delete

    3.2.1close方法

    作用:关闭数据库。

    3.2.2query方法

    1.作用:查询记录得到的对象是一个游标对象

    • 参数分别是 表名,查询的字段集合,条件,动态条件, 分组, 筛选,排序

    1. Cursor cursor= database.query("student",new String[]{"id,name,age"},null,null,null,null,null);

    3.2.3insert方法

    ContentValues是不能存储对象的,只能存储普通的键值对

    1.通过execSQL的方式

    2.通过直接进行insert的方式

    3.参数

    • 插入数据的返回值是查插入数据的行id,是long类型的值,值为-1的话就是显示插入错误

    • 表名,为null的列明,要插入的数据,需要用到指定的类ContentValues进行数据的插入操作,采用的是键值对的形式进行存储的

    1. ContentValues values=new ContentValues();
    2. values.put("name","张三");
    3. values.put("age","20");
    4. long x=database.insert("student",null,values);

    3.2.4delete方法

    1.参数:

    • 参数:表名,删除条件,删除条件参数数组

    • 返回值:删除的行数,为0为删除失败

    2.作用:

      int z= database.delete("student","id=?",new String[]{"1"});

    3.2.5update方法

    1. 参数:

    • 表名,更新的数据ContenValues,条件,where中传入的参数

    • 返回值:int类型

    2.作用:

       
    
    1. ContentValues value=new ContentValues();
    2. values.put("name","李四");
    3. int y=database.update("student",value,"id=?",new String[]{"1"});
     
    

    3.2.6execSQL

    1.作用:执行原声的sql语句,后面的ContentProvider最常用。除了查询都是这一个方法。

    execSQL的方式可以动态的输入参数的值。

    3.2.7rawQuery方法

    1.传入的值一个为sql语句 ,第二个是占位符中的条的值。条件可以设置为null。

    占位符可以设置多个,可以通过占位符进行模糊查询。

    3.2.8Cursor游标

    1.简介:就是一个结果集合,可以对结果进行随机的访问,也可以理解为一个指针,每次执行一个next会从一个元组跳转到下一个元组上去

    2.游标:指定定位的位置的那一刻返回元组数据。

    常见的方法如下:

    • moveToPrevious:从当前行移动到上一行,返回值是false或者是true

    • moveToFirst:从当前行移动到第一行,返回值是false或者是true

    • moveToLast:从当前行移动到最后一行

    • moveToPosition(int position),从当前记录的指针移动到指定的位置处。

    • move(int offset):从当前位置往闪上或者是往下移动指定的位置,为正数表示向下移动,为负数表示向上移动。

    3.游标获取参数的方法

    • getColumenName(int indx):给定指定的索引返回列名,从0开始。

    • getColumnIndex(String columnName):根据列名获取从0开始的索引,没有的话就返回-1.

    • getInt(int columnIndex):获取指定索引列的整数值

    • getString(int columnIndex):获取指定索引列的字符串

      一般来说的话是通过getInt或者是getString获取指定列中的数据。

    4.基于SQLite的增删改查操作

    4.1案例:基于SQLite的学生管理系统

    1.项目目录结构如下

     

    2.实体类代码如下:

    1. //实体类
    2. public class Student {
    3. private int id;
    4. private String name;
    5. private String age;
    6. public Student(int id, String name, String age) {
    7. this.id = id;
    8. this.name = name;
    9. this.age = age;
    10. }
    11. public Student() {
    12. }
    13. public int getId() {
    14. return id;
    15. }
    16. public void setId(int id) {
    17. this.id = id;
    18. }
    19. public String getName() {
    20. return name;
    21. }
    22. public void setName(String name) {
    23. this.name = name;
    24. }
    25. public String getAge() {
    26. return age;
    27. }
    28. public void setAge(String age) {
    29. this.age = age;
    30. }
    31. @Override
    32. public String toString() {
    33. return "Student{" +
    34. "id=" + id +
    35. ", name='" + name + '\'' +
    36. ", age='" + age + '\'' +
    37. '}';
    38. }
    39. }

    3.dao层下的代码如下。

    1)接口的定义

    1. //===定义相关操作数据库的方法
    2. public interface StudentDao {
    3. // 增加数据方法
    4. public void addStudent(Context context,Student student);//添加学生
    5. public List getStudents(Context context);//获取全部学生
    6. public void deleteStudent(Context context,Student student);//删除指定学生的信息
    7. public void updateStudent(Context context,Student student);//更新指定学生的信息
    8. }

    2)接口实现类的定义

    1. //===操作数据库的实现类
    2. public class StuidentDaoImpl implements StudentDao{
    3. // 增加数据方法
    4. public void addStudent(Context context, Student student){
    5. //数据库帮助类
    6. MySQLitehelper mySQLitehelper=new MySQLitehelper(context,"syudentdb",1);
    7. SQLiteDatabase database=mySQLitehelper.getWritableDatabase();
    8. database.execSQL("insert into student(name,age) values(?,?)",new String[]{student.getName(),student.getAge()});
    9. };
    10. //获取全部学生
    11. public List<Student> getStudents(Context context){
    12. MySQLitehelper mySQLitehelper=new MySQLitehelper(context,"syudentdb",1);
    13. SQLiteDatabase database=mySQLitehelper.getWritableDatabase();
    14. Cursor cursor=database.rawQuery("select * from student",null);
    15. //创建一个集合
    16. List<Student> list=new ArrayList<>();//创建一个集合
    17. //循环查询数据
    18. while(cursor.moveToNext()){
    19. Student student=new Student();
    20. student.setId(cursor.getInt(0));
    21. student.setName(cursor.getString(1));
    22. student.setAge(cursor.getString(2));
    23. list.add(student);
    24. }
    25. return list;
    26. };//获取全部学生
    27. public void deleteStudent(Context context,Student student) {
    28. MySQLitehelper mySQLitehelper=new MySQLitehelper(context,"syudentdb",1);
    29. SQLiteDatabase database=mySQLitehelper.getWritableDatabase();
    30. database.execSQL("delete from student where id=?",new String[]{student.getId()+""});
    31. }
    32. //删除指定学生的信息
    33. public void updateStudent(Context context,Student student){
    34. MySQLitehelper mySQLitehelper=new MySQLitehelper(context,"syudentdb",1);
    35. SQLiteDatabase database=mySQLitehelper.getWritableDatabase();
    36. database.execSQL("update student set name=? ,age=? where id=?",new String[]{student.getName(),student.getAge(),student.getId()+""});
    37. };//更新指定学生的信息
    38. }

    4.SQLiteHelper数据库连接帮助类的定义

    1. //===数据库帮助类
    2. public class MySQLitehelper extends SQLiteOpenHelper {
    3. // 构造方法
    4. public MySQLitehelper(@Nullable Context context, @Nullable String name, @Nullable SQLiteDatabase.CursorFactory factory, int version) {
    5. super(context, name, factory, version);
    6. }
    7. // 创建一个不需要游标的构造方法
    8. public MySQLitehelper(@Nullable Context context, @Nullable String name, int version) {
    9. super(context, name, null, version);
    10. }
    11. // 创建数据库表的方法
    12. @Override
    13. public void onCreate(SQLiteDatabase db) {
    14. //此方法再创建此类的对象后进行回调,编写一条可以执行的sql语句
    15. db.execSQL("create table student (id INTEGER primary key autoincrement,name varchar(20),age varchar(10))");
    16. }
    17. // 更新数据库表表的方法
    18. @Override
    19. public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {
    20. //当版本号发生更新的时候进行回调
    21. //一般是田家炳新的数据库字段的时候进行回调
    22. db.execSQL("alter table student add sex varchar(10)");
    23. }
    24. }

    5.主启动类的代码如下。

    主要涉及到的方法是增删改查的方法。

    1. public class MainActivity extends AppCompatActivity {
    2. //定义控件元素
    3. EditText id;
    4. EditText name;
    5. EditText age;
    6. Button add,delete,update,query;
    7. ListView listView;
    8. @Override
    9. protected void onCreate(Bundle savedInstanceState) {
    10. super.onCreate(savedInstanceState);
    11. setContentView(R.layout.activity_main);
    12. //1.获取控件对象
    13. initView();
    14. //2.解析布局
    15. //布局文件的事件监听
    16. listViewListener();
    17. //调用增删改查的方法
    18. addListener();
    19. deleteListener();
    20. updateListener();
    21. quertyListener();
    22. }
    23. // 方法:获取控件对象
    24. public void initView(){
    25. //获取控件对象
    26. id=findViewById(R.id.id);
    27. name=findViewById(R.id.name);
    28. age=findViewById(R.id.age);
    29. add=findViewById(R.id.add);
    30. delete=findViewById(R.id.delete);
    31. update=findViewById(R.id.update);
    32. query=findViewById(R.id.query);
    33. listView=findViewById(R.id.listview);
    34. //添加标题头的信息
    35. View view=LayoutInflater.from(this).inflate(R.layout.student_itemtitle,null);
    36. listView.addHeaderView(view);
    37. //设置学生的编号不可以被点击
    38. id.setClickable(false);
    39. id.setFocusable(false);
    40. id.setEnabled(false);//会变灰
    41. }
    42. // 方法:设置add事件监听
    43. public void addListener(){
    44. add.setOnClickListener(new View.OnClickListener() {
    45. @Override
    46. public void onClick(View v) {
    47. //获取学生的信息
    48. // String uid=id.getText().toString();测试采用的插入的方式是主键自增的方式
    49. String uname=name.getText().toString();
    50. String uage=age.getText().toString();
    51. Student student=new Student();
    52. student.setName(uname);
    53. student.setAge(uage);
    54. //创建操作数据库的类
    55. StudentDao studentDao=new StuidentDaoImpl();
    56. studentDao.addStudent(getApplicationContext(),student);
    57. Toast.makeText(MainActivity.this, "增加成功", Toast.LENGTH_SHORT).show();
    58. }
    59. });
    60. }
    61. // 删除事件监听
    62. public void deleteListener(){
    63. delete.setOnClickListener(new View.OnClickListener() {
    64. @Override
    65. public void onClick(View v) {
    66. //获取学生的信息
    67. String uid=id.getText().toString();//测试采用的插入的方式是主键自增的方式
    68. String uname=name.getText().toString();
    69. String uage=age.getText().toString();
    70. Student student=new Student();
    71. if (!uid.equals(""))//不能为空
    72. {//创建操作数据库的类
    73. student.setId(Integer.parseInt(uid));
    74. student.setName(uname);
    75. student.setAge(uage);
    76. StudentDao studentDao=new StuidentDaoImpl();
    77. studentDao.deleteStudent(getApplicationContext(),student);
    78. Toast.makeText(MainActivity.this, "删除成功", Toast.LENGTH_SHORT).show();
    79. }
    80. else{
    81. Toast.makeText(MainActivity.this, "删除失败!", Toast.LENGTH_SHORT).show();
    82. }
    83. }
    84. });
    85. }
    86. // 更新事件监听
    87. public void updateListener(){
    88. update.setOnClickListener(new View.OnClickListener() {
    89. @Override
    90. public void onClick(View v) {
    91. //获取学生的信息
    92. String uid=id.getText().toString();//测试采用的插入的方式是主键自增的方式
    93. String uname=name.getText().toString();
    94. String uage=age.getText().toString();
    95. Student student=new Student();
    96. if (!uid.equals(""))//不能为空
    97. {//创建操作数据库的类
    98. student.setId(Integer.parseInt(uid));
    99. student.setName(uname);
    100. student.setAge(uage);
    101. StudentDao studentDao=new StuidentDaoImpl();
    102. studentDao.updateStudent(getApplicationContext(),student);
    103. Toast.makeText(MainActivity.this, "修改成功", Toast.LENGTH_SHORT).show();
    104. }
    105. else{
    106. Toast.makeText(MainActivity.this, "删除失败!", Toast.LENGTH_SHORT).show();
    107. }
    108. }
    109. });
    110. }
    111. // 查询事件监听
    112. public void quertyListener(){
    113. query.setOnClickListener(new View.OnClickListener() {
    114. @Override
    115. public void onClick(View v) {
    116. StudentDao studentDao=new StuidentDaoImpl();
    117. List<Student> list=studentDao.getStudents(getApplicationContext());//获取全部的学生的信息
    118. //调用显示界面的方法
    119. initListView(list);
    120. }
    121. });
    122. }
    123. //方法:显示界面的内容
    124. public void initListView(List<Student> list){
    125. //创建表一个只能保存map的集合
    126. List<Map<String,String>> list1=new ArrayList<>();
    127. //遍历添加数据
    128. for (int i=0;i<list.size();i++){
    129. Map<String,String> map=new HashMap<>();
    130. map.put("text_1",list.get(i).getId()+"");
    131. map.put("text_2",list.get(i).getName());
    132. map.put("text_3",list.get(i).getAge());
    133. list1.add(map);
    134. }
    135. //创建适配器并进行v适配器的绑定
    136. SimpleAdapter simpleAdapter=new SimpleAdapter(getApplicationContext(),list1,R.layout.student_item,new String[]{"text_1","text_2","text_3"},new int[]{R.id.text_1,R.id.text_2,R.id.text_3});
    137. listView.setAdapter(simpleAdapter);
    138. }
    139. // 设置列表项的事件监听
    140. public void listViewListener(){
    141. listView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
    142. @Override
    143. public void onItemClick(AdapterView<?> parent, View view, int position, long id1) {
    144. TextView text_1=view.findViewById(R.id.text_1);
    145. TextView text_2=view.findViewById(R.id.text_2);
    146. TextView text_3=view.findViewById(R.id.text_3);
    147. if (position==0){
    148. id.setText("");
    149. name.setText("");
    150. age.setText("");
    151. }
    152. else{
    153. id.setText(text_1.getText());
    154. name.setText(text_2.getText());
    155. age.setText(text_3.getText());
    156. }
    157. }
    158. });
    159. }
    160. }

    6.列表项的布局文件

    • 表头的布局文件

    • 列表项的布局文件

    • 主启动类的布局文件

    1)表头的布局文件

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    3. android:orientation="horizontal"
    4. android:layout_width="match_parent"
    5. android:layout_height="match_parent">
    6. <!--标头的布局文件-->
    7. <TextView
    8. android:layout_width="0dp"
    9. android:gravity="center"
    10. android:layout_weight="1"
    11. android:layout_height="wrap_content"
    12. android:text="学生编号"
    13. android:textSize="25dp"
    14. />
    15. <TextView
    16. android:layout_width="0dp"
    17. android:gravity="center"
    18. android:layout_weight="1"
    19. android:layout_height="wrap_content"
    20. android:text="学生姓名"
    21. android:textSize="25dp"
    22. />
    23. <TextView
    24. android:layout_width="0dp"
    25. android:gravity="center"
    26. android:layout_weight="1"
    27. android:layout_height="wrap_content"
    28. android:text="学生年龄"
    29. android:textSize="25dp"
    30. />
    31. </LinearLayout>

    2)列表项的布局文件

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    3. android:orientation="horizontal"
    4. android:layout_width="match_parent"
    5. android:layout_height="match_parent">
    6. <!--标头的布局文件-->
    7. <TextView
    8. android:id="@+id/text_1"
    9. android:layout_width="0dp"
    10. android:gravity="center"
    11. android:layout_weight="1"
    12. android:layout_height="wrap_content"
    13. android:text="学生编号"
    14. android:textSize="25dp"
    15. />
    16. <TextView
    17. android:id="@+id/text_2"
    18. android:layout_width="0dp"
    19. android:gravity="center"
    20. android:layout_weight="1"
    21. android:layout_height="wrap_content"
    22. android:text="学生姓名"
    23. android:textSize="25dp"
    24. />
    25. <TextView
    26. android:id="@+id/text_3"
    27. android:layout_width="0dp"
    28. android:gravity="center"
    29. android:layout_weight="1"
    30. android:layout_height="wrap_content"
    31. android:text="学生年龄"
    32. android:textSize="25dp"
    33. />
    34. </LinearLayout>

    3)主启动类的布局文件

    1. <?xml version="1.0" encoding="utf-8"?>
    2. <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    3. xmlns:app="http://schemas.android.com/apk/res-auto"
    4. xmlns:tools="http://schemas.android.com/tools"
    5. android:orientation="vertical"
    6. android:layout_width="match_parent"
    7. android:layout_height="match_parent">
    8. <!--学生编号-->
    9. <LinearLayout
    10. android:orientation="horizontal"
    11. android:layout_width="match_parent"
    12. android:layout_height="wrap_content">
    13. <TextView
    14. android:layout_width="wrap_content"
    15. android:layout_height="wrap_content"
    16. android:text="学生编号"
    17. android:textSize="25dp"
    18. android:textColor="@color/black"
    19. />
    20. <EditText
    21. android:layout_weight="1"
    22. android:id="@+id/id"
    23. android:layout_width="0dp"
    24. android:layout_height="wrap_content"
    25. android:textSize="25dp"
    26. />
    27. </LinearLayout>
    28. <!-- 学生姓名-->
    29. <LinearLayout
    30. android:orientation="horizontal"
    31. android:layout_width="match_parent"
    32. android:layout_height="wrap_content">
    33. <TextView
    34. android:layout_width="wrap_content"
    35. android:layout_height="wrap_content"
    36. android:text="学生姓名"
    37. android:textSize="25dp"
    38. android:textColor="@color/black"
    39. />
    40. <EditText
    41. android:layout_weight="1"
    42. android:id="@+id/name"
    43. android:layout_width="0dp"
    44. android:layout_height="wrap_content"
    45. android:textSize="25dp"
    46. />
    47. </LinearLayout>
    48. <!-- 学生年龄-->
    49. <LinearLayout
    50. android:orientation="horizontal"
    51. android:layout_width="match_parent"
    52. android:layout_height="wrap_content">
    53. <TextView
    54. android:layout_width="wrap_content"
    55. android:layout_height="wrap_content"
    56. android:text="学生年龄"
    57. android:textSize="25dp"
    58. android:textColor="@color/black"
    59. />
    60. <EditText
    61. android:id="@+id/age"
    62. android:layout_width="0dp"
    63. android:layout_weight="1"
    64. android:layout_height="wrap_content"
    65. android:textSize="25dp"
    66. />
    67. </LinearLayout>
    68. <!-- 按钮区域-->
    69. <LinearLayout
    70. android:layout_width="match_parent"
    71. android:layout_height="wrap_content"
    72. android:orientation="horizontal"
    73. >
    74. <Button
    75. android:id="@+id/add"
    76. android:layout_width="0dp"
    77. android:layout_height="wrap_content"
    78. android:layout_weight="1"
    79. android:text="增加"
    80. />
    81. <Button
    82. android:id="@+id/delete"
    83. android:layout_width="0dp"
    84. android:layout_height="wrap_content"
    85. android:layout_weight="1"
    86. android:text="删除"
    87. />
    88. <Button
    89. android:id="@+id/update"
    90. android:layout_width="0dp"
    91. android:layout_height="wrap_content"
    92. android:layout_weight="1"
    93. android:text="修改"
    94. />
    95. <Button
    96. android:id="@+id/query"
    97. android:layout_width="0dp"
    98. android:layout_height="wrap_content"
    99. android:layout_weight="1"
    100. android:text="查询"
    101. />
    102. </LinearLayout>
    103. <!-- 显示列表项信息-->
    104. <LinearLayout
    105. android:orientation="vertical"
    106. android:layout_width="match_parent"
    107. android:layout_height="wrap_content">
    108. ` <ListView
    109. android:id="@+id/listview"
    110. android:layout_width="match_parent"
    111. android:layout_height="wrap_content"/>
    112. </LinearLayout>
    113. </LinearLayout >

    6.运行的效果图

     

  • 相关阅读:
    【Hyperledger Fabric 学习】部署智能合约到通道上
    抖音矩阵系统-60+自媒体平台一键发布-短视频获客系统
    命令模式,命令 Command 类对象的设计(设计模式与开发实践 P9)
    Vue - 实现获取手机验证码倒计时 60 秒(手机号+验证码登录功能)
    Js手写面试题5-Promise
    软考高级之系统架构师之软件需求工程
    天猫/淘宝1688API接口大全
    GreenPlum简介
    Windows7 - 永恒之蓝 - 测试
    Spring事务不生效的场景的解决方案
  • 原文地址:https://blog.csdn.net/weixin_41957626/article/details/128026328