ListView显示数据库的数据-采用自定义布局-向上滑动可以加载更多数据

该博客介绍了如何在ListView中利用自定义布局显示从数据库(如用户名、手机号)获取的数据,并实现上滑加载更多数据的功能。涉及到的步骤包括自定义user_item.xml布局文件,MainActivity中添加ListView,创建UserAdapter适配器,以及数据库操作如HytcSQLiteOpenHelper和UserDao的相关方法。
摘要由CSDN通过智能技术生成

本案例使用自定义布局实现在ListView中显示数据库的数据(用户名、手机号)的功能,ListView向上滑动可以加载更多数据。
这里写图片描述

1.user_item.xml
这里写图片描述

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="horizontal" >

    <TextView
        android:id="@+id/tv_name"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_marginLeft="10dp"
        android:layout_weight="1"
        android:text="chj" />

    <TextView
        android:id="@+id/tv_phone"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="2"
        android:text="13527168697" />

    <Button
        android:id="@+id/btn_call"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="拨号" />

    <Button
        android:id="@+id/btn_sms"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"
        android:text="信息" />

</LinearLayout>

这里写图片描述

2.在activity_main.xml中添加ListView控件 id=”@+id/lv_users”

3.自定义的adapter UserAdapter.java
这里写图片描述

package com.example.dbhytc.adapter;

import java.util.List;
import java.util.Map;

import android.content
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值