简体   繁体   English

将textview添加到listview

[英]Add a textview to the listview

Friends. 朋友们 I am doing one android application. 我正在做一个Android应用程序。 In that application I want to show total number of list items as a final column. 在该应用程序中,我想显示列表项的总数作为最后一列。 so my question is "Is it possible to add a TextView to the ListView as final column.?" 所以我的问题是“是否可以将TextView作为最后一列添加到ListView ?” like the following image. 如下图所示。

在此处输入图片说明

I was searching lot through internet friends. 我在通过互联网朋友搜索很多东西。 But the solution is mostly like combine two ListView and add views dynamically to the ListView . 但是解决方案大多类似于合并两个 ListView并将视图动态添加到ListView Thats why I need your help friends. 这就是为什么我需要您的帮助朋友。

Thanks in Advance 提前致谢

Use this : 用这个 :

list.addFooterView(textView);

ListView 列表显示

Hope this helped you. 希望这对您有所帮助。

You can use 您可以使用

list.addFooterView(v). 

Make sure that you are adding the view before you setting the adapter to the list. 将适配器设置为列表之前,请确保要添加视图。 For more check out this . 有关更多信息, 请查看此

Try this... 尝试这个...

    ListView v = getListView();   
    TextView tv=new TextView(this);
    tv.setText("total number of items: 114");
    v.addFooterView(tv);

I think a simple solution is to count the number of list items before setting your adapter, with yourTable.length(); 我认为一种简单的解决方案是在设置适配器之前使用yourTable.length();计算列表项的数量yourTable.length();

Then maybe you can add a row in this table with your "Total Number of items xxx" instead of the date and an empty title. 然后,也许您可​​以在此表中添加一行,其中包含“项目总数xxx”,而不是日期和空标题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM