欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

Android 處理空列表的方法(必看篇)

 更新時間:2017年04月18日 10:13:33   投稿:jingxian  
下面小編就為大家?guī)硪黄狝ndroid 處理空列表的方法(必看篇)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧

android中ListView 用來展示數(shù)據(jù),如果列表為空的狀態(tài),可以通過setEmpty(View)方法設(shè)置為空時顯示的內(nèi)容。

布局xml

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical" >

  <ListView
    android:id="@+id/my_list_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" />

  <ImageView
    android:id="@+id/empty_view"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:src="@drawable/empty_view" />

</FrameLayout>

代碼:

public class Hack24Activity extends Activity {
  private ListView mListView;
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_hack24);

    mListView = (ListView) findViewById(R.id.my_list_view);
    mListView.setEmptyView(findViewById(R.id.empty_view));

  }
}

以上這篇Android 處理空列表的方法(必看篇)就是小編分享給大家的全部內(nèi)容了,希望能給大家一個參考,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論