android – 在ListActivity上使用setEmptyView的问题

android – 在ListActivity上使用setEmptyView的问题,第1张

概述我有以下设置,空视图文本没有显示… protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); getListView().setEmptyView(findViewById(R.id.empty)); getListView().setTe 我有以下设置,空视图文本没有显示…

protected voID onCreate(Bundle savedInstanceState) {    super.onCreate(savedInstanceState);            getListVIEw().setEmptyVIEw(findVIEwByID(R.ID.empty));    getListVIEw().setTextFilterEnabled(true);    setlistadapter(null);// to have empty List}

布局文件是:

<?xml version="1.0" enCoding="utf-8"?><linearLayout androID:ID="@+ID/myScrollLayout"    androID:layout_wIDth="fill_parent" androID:layout_height="fill_parent"    androID:orIEntation="vertical" xmlns:androID="http://schemas.androID.com/apk/res/androID">    <FrameLayout androID:layout_wIDth="fill_parent"        androID:layout_height="0dip" androID:layout_weight="1">        <ListVIEw androID:ID="@androID:ID/List" androID:layout_wIDth="fill_parent"            androID:layout_height="fill_parent" androID:drawSelectorOntop="false" />        <!-- Here is the vIEw to show if the List is emtpy -->        <ScrollVIEw            androID:ID="@androID:ID/empty" androID:layout_wIDth="fill_parent"            androID:layout_height="fill_parent">            <TextVIEw androID:ID="@+ID/emptyText" androID:layout_wIDth="fill_parent"                androID:layout_height="fill_parent" androID:text="@string/contact_empty_help"                androID:textSize="20sp" androID:textcolor="?androID:attr/textcolorSecondary"                androID:paddingleft="10dip" androID:paddingRight="10dip"                androID:paddingtop="10dip" androID:linespacingMultiplIEr="0.92" />        </ScrollVIEw>    </FrameLayout></linearLayout>

字符串定义为:

<string name="contact_empty_help">"You don't have any contacts to display.\n\nTo add contacts,you have to:\n        \n<li><Font fgcolor="#ffffffff">Go to <b>Contacts</b></Font> application to create new contacts\n</li>        \n<li><Font fgcolor="#ffffffff"><b>import from VCF file</b></Font>,this is available in Contacts menu,the file most be on the root of the SD card\n</li>"        </string>

由于列表为空,它应该显示已定义的文本.我按照List8中的示例进行 *** 作

https://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/List8.html
https://developer.android.com/resources/samples/ApiDemos/res/layout/list_8.xml

解决方法 我错过了一个setContentVIEw(R.layout.ListvIEw);因此,findVIEwByID没有提取视图. 总结

以上是内存溢出为你收集整理的android – 在ListActivity上使用setEmptyView的问题全部内容,希望文章能够帮你解决android – 在ListActivity上使用setEmptyView的问题所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1121694.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-29
下一篇2022-05-29

发表评论

登录后才能评论

评论列表(0条)

    保存