我的活动onCreate看起来像这样:
@OverrIDe protected voID onCreate(Bundle savedInstanceState) { // Todo auto-generated method stub super.onCreate(savedInstanceState); setContentVIEw(R.layout.favorite_exams); List = (ListVIEw) findVIEwByID(R.ID.favoriteExamsList); VIEw empty = findVIEwByID(R.ID.favoriteExamslistemptyVIEw); List.setEmptyVIEw(empty); new readingFavfileTask().execute(UtilityFuctions.FAV_EXAMS_file_name); }
我的布局文件是:
<?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="vertical" > <ListVIEw androID:ID="@+ID/favoriteExamsList" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" > </ListVIEw> <linearLayout androID:ID="@+ID/favoriteExamslistemptyVIEw" androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent" androID:orIEntation="vertical" androID:visibility="gone" > <TextVIEw androID:ID="@+ID/favoriteExamsEmptyVIEwMessage" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:layout_margintop="10dp" androID:text="You do not have any favorite Exams.Please add Exams using below button." androID:textSize="20dp" /> <button androID:ID="@+ID/favoriteExamsAdd" androID:layout_wIDth="fill_parent" androID:layout_height="wrap_content" androID:layout_gravity="center_horizontal" androID:onClick="onClickAddExams" androID:text="Add Exams" > </button> </linearLayout></linearLayout>
如果我们在我们的适配器中有数据,我如何确保空视图永远不会显示一秒钟.我应该在检查适配器之后将空视图附加到列表中,还是以任何其他方式执行此 *** 作?
解决方法 我找到了答案.在将我的适配器设置为List之后,我只需要在我的AsyncTask onPostExecute()方法中应用Empty VIEw List.setEmptyVIEw(empty),它就可以正常工作. 总结以上是内存溢出为你收集整理的android – 为什么即使listview有项目,布局文件中的空视图也会显示在屏幕上?全部内容,希望文章能够帮你解决android – 为什么即使listview有项目,布局文件中的空视图也会显示在屏幕上?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)