如何显示在孩子所有的列表项的ListView,使用CWAC合并-1.0.4罐 [英] How to show All list items in child ListView-using cwac-merge-1.0.4 jar

查看:234
本文介绍了如何显示在孩子所有的列表项的ListView,使用CWAC合并-1.0.4罐的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的,因为使用两个列表视图可能父的ListView 和<$ C两ListView控件在同一屏幕上, $ C>儿童的ListView ,那个孩子的ListView 适配器类不显示在儿童ListView.It所有列表值显示,只有 0次(第一次)的位置,这上面的问题,我已经使用了答案code,从这个的 Android的列表视图滚动视图内link.now我可以看到所有的列表值我儿童的ListView 但它没有显示这是我从已经抓住了在同一时间我所有的列表值 Web服务调用。它只能在榜单显示第一个值,因为列表视图高度设置以列表的height.If我向下滚动儿童的ListView我能看到ListView.What我需要的是,如果我得到的Web服务,具有显示所有五个项目中同时列出五个值的所有值的单个项目。

I am using two ListView in same screen,Because of using two Listviews likely Parent ListView and Child ListView,that Child ListView Adapter class doesn't show all List Values in Child ListView.It showed only 0 th(first) position in Child ListView,for this above issue I have used the answer code from this Android list view inside a scroll view link.now I can see all list values in my Child ListView but It is not showing all my List values in same time which I had grabbed from Web service call.It showed first value only in list because the List View height was set to list's single item height.If I scroll down the Child ListView I am able to see all values in ListView.What I need is If i get five list values from Web service It has to show all five items in same time.

注意::如果我设置列表硬codeD值,这表明在儿童的ListView的所有项目在同一时间

note: If I set hard coded values for List,It showed all items in Child ListView at one time.

编辑

使用MergeAdapter如何我做到了这一点

createAdapter 方法将返回适配器对象,我一直使用<$ C $设置适配器插入我的列表视图C> setAdapter(createAdapter(新的ArrayList&LT; T&GT;()))

This createAdapter method would return Adapter object and I have set that Adapter into my Listview using setAdapter(createAdapter(new ArrayList<T>()))

 private ListAdapter createAdapter(List<T> items) {

        mergeAdapter = new MergeAdapter();
        mergeAdapter.addAdapter(endlessFeedAdapter);       

        return  mergeAdapter;
    }

我需要的是

我一直在建议使用双列表视图 ExpandableListView 而不是使用。 如果我使用 ExpandableListView 我将不得不修改 createAdapter 方法的返回类型为 ExpandableListAdapter 为了这个,我在下面用code

I Have been suggested to use ExpandableListView instead of using two ListViews. If I use ExpandableListView I will have to change the createAdapter method return type into ExpandableListAdapter for this I used below code

 private ExpandableListAdapter createAdapter(List<T> items) {

            mergeAdapter = new MergeAdapter();
            mergeAdapter.addAdapter(endlessFeedAdapter);       

            return (ExpandableListAdapter) mergeAdapter;
        }

但它显示了以下 Excaption

致:java.lang.ClassCastException:com.commonsware.cwac.merge.MergeAdapter不能转换为android.widget.ExpandableListAdapter 从Web服务值

硬codeD值

推荐答案

什么是阻止你做2个不同的适配器,并将它们添加到MergeAdapter?您可以添加多个适配器MergeAdapter和多个视图。在这种情况下,没有必要用2列表视图。

What is stopping you to make 2 different adapters and adding them to MergeAdapter? You can add multiple adapters to MergeAdapter and multiple views. In that case there is no need to use 2 Listviews.

mergeAdapter.addAdapter(adapterHeading);
mergeAdapter.addView(someView);
mergeAdapter.addAdapter(adapterFooter);
listView.setAdapter(mergeAdapter);

这篇关于如何显示在孩子所有的列表项的ListView,使用CWAC合并-1.0.4罐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆