<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>
<shape xmlns:android = "http://schemas.android.com/apk/res/android" android:shape= "rectangle" > <solid android:color= "#AA00FF00" /> </shape>
public class MainActivity extends Activity { private ListView mListView; @Override public void onCreate (Bundle savedInstanceState ) { super. onCreate( savedInstanceState ); setContentView (R .layout .main ); mListView = (ListView ) findViewById (R .id .my_list_view ); mListView. setEmptyView (findViewById (R .id .empty_view )); /*String[] strs=new String[]{"1","2"}; ArrayAdapter<String> adapter=new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,strs); mListView.setAdapter(adapter);*/ } }
50个Android开发技巧(24 处理ListView数据为空的情况),布布扣,bubuko.com
50个Android开发技巧(24 处理ListView数据为空的情况)
原文:http://www.cnblogs.com/mfrbuaa/p/3795368.html