Android的ListView的另一水平的ListView [英] android listView another horizontal listView

查看:104
本文介绍了Android的ListView的另一水平的ListView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要寻找任何方式,我可以把Android的ListView控件与TextView的,并对应于另一个的ListView ListView的水平。

I am looking for any way by which I can place android listView with TextView and another horizontal listView corresponding to that listView.

其实我有对应于项目我有子类项目和商店的名单。

Actually I'm having a List of items and shops corresponding to that item I have sub categories.

也是一个店可以拥有多个子类别,如它,S不同的子类(子)。

And also a shop can have multiple sub categories like it,s different sub categories(child).

要显示的情况一样,

..............................

................................................

吃(文字版)

图片图片图片(多个类别中的项目)......

Image Image Image (multiple categories in that item) .....

名称名称名称(多个类别中的项目)

Name Name Name (multiple categories in that item)

.............................. .............

............................................................

推荐答案

使用的ArrayAdaptor:看在谷歌定制的ListView:(第一个结果)的http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/

Use an ArrayAdaptor : look custom ListView on google : (first result) http://www.softwarepassion.com/android-series-custom-listview-items-and-adapters/

基本上你需要来设计XML的子表的布局,然后设计你的主要的ListView的布局XML。

Basically you need to design the layout of your sublist in XML, then design the layout of your main ListView in XML.

我觉得你对子级使用 WRAP_CONTENT 为您的子列表,宽度: FILL_PARENT 的主列表和高度: WRAP_CONTENT 的主列表。
然后,你需要两个类来保存您需要的每个项目的数据(一个包含您的子列表中的一个主列表)。

I think you whould use wrap_content for your sublist, width : fill_parent for the main list and height : wrap_content for the main list. Then you need two classes to hold your required data of each item (one for the main list containing one of your sublist).

然后创建的ArrayList和ArrayList(存储在每个MyMainItem)。
然后,你需要创建两个类extenting ArrayAdaptor:
MainAdapter扩展ArrayAdaptor和SecondaryAdapter

Then you create ArrayList and ArrayList (stored in each MyMainItem). Then you'll need to create two class extenting ArrayAdaptor : MainAdapter extends ArrayAdaptor and SecondaryAdapter

在每个ArrayAdapter的你需要存储项目的列表,并重写构造函数,像这样:

In each of your ArrayAdapter you'll need to store the list of items and override the constructor like so :

private ArrayList<MyObj> items = new ArrayList<MyObj>();


    public ArticlesAdapter(Context context, int textViewResourceId,
            ArrayList<MyObj> items) {
        super(context, textViewResourceId, items);
        this.items = items;
    }

在每一个适配器,你就必须要覆盖的方法

In each adaptor, you'll have to override the method

@Override
public View getView(int position, View convertView, ViewGroup parent) 

就像在教程中所示
但是,不要在你的MainAdapter调用setAdaptor()在subListView忘记。
小心的getView方法:你是高度收到一个空的对象,所以一定要测试它,以避免NullPointerException异常

like shown in the tutorial But don't forget in your MainAdapter to call the setAdaptor() on the subListView. Be careful with the getView method : you are highly to receive a null object, so make sure to test it to avoid NullPointerException

希望我帮你。这是值得一赏金: - )

Hope I helped you. This is worth a Bounty :-)

这篇关于Android的ListView的另一水平的ListView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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