Android应用中使用ListView来分页显示刷新的内容

2019-12-10 18:12:04王冬梅

 

<RelativeLayout xmlns:android="http://www.easck.com/apk/res/android" 
 xmlns:tools="http://www.easck.com/tools" 
 android:layout_width="match_parent" 
 android:layout_height="match_parent" 
 tools:context=".MainActivity" > 
 
 <ListView 
  android:id="@+id/newsShow_list" 
  android:layout_width="match_parent" 
  android:layout_height="wrap_content" > 
 </ListView> 
 
 <LinearLayout 
  android:layout_width="match_parent" 
  android:layout_height="wrap_content" 
  android:layout_alignParentBottom="true" > 
 
  <Button 
   android:id="@+id/adddata" 
   android:layout_width="wrap_content" 
   android:layout_height="wrap_content" 
   android:layout_weight="1" 
   android:text="添加数据" /> 
 
  <Button 
   android:id="@+id/loadmore_bt" 
   android:layout_width="wrap_content" 
   android:layout_height="wrap_content" 
   android:layout_weight="1" 
   android:text="@string/loadmore" /> 
 </LinearLayout> 
 
</RelativeLayout> 

 

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://www.easck.com/apk/res/android" 
 android:layout_width="match_parent" 
 android:layout_height="match_parent" 
 android:padding="15dp" 
 android:orientation="horizontal" > 
 
 <ImageView 
  android:id="@+id/showimage_title" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content" 
  android:background="@drawable/n_me_l" 
  android:contentDescription="@string/imagenews" /> 
 
 <TextView 
  android:id="@+id/txt_title" 
  android:layout_width="wrap_content" 
  android:layout_height="wrap_content" /> 
 
</LinearLayout> 

下拉刷新
当ListView要显示的数据过多时,为了更快的响应用户,这个时候ListView进行分页显示再合适不过了。