English 中文(简体)
and • 如何利用同一群体和儿童的同一类别扩大可扩展的ListAdapter?
原标题:android: How to ExpandableListAdapter using the same class for group and child?
  • 时间:2011-10-09 21:04:12
  •  标签:
  • android

I m 试图使用和扩大的ListView 植被。 我有一个类别项目,它对一个项目有许多属性。 我希望我的清单照样,小组名单的内容只显示该项目的名称和其他一些重要属性。 当点击该项目时,它扩大并展示了特定项目的所有属性。 因此,对我来说,这一群体和儿童因素基本相同,我扩大的名单总是只有一个内容。 这样做的恰当方式是撰写适应者。 我曾尝试过这样的事情,但总是在我想扩大一个要素时,让我放弃点。

private Context context;
private ArrayList<VCDR> groups;
private ArrayList<ArrayList<VCDR>> children;


public ExpandableAdapter(Context context, ArrayList<VCDR> groups) {
    this.context = context;
    this.groups = groups;
    this.children= new ArrayList<ArrayList<VCDR>>();
    this.children.add(groups);

}


public Object getChild(int groupPosition, int childPosition) {

    return children.get(groupPosition).get(childPosition);
}
问题回答

我设法做到了,我正在努力做些什么。 我不敢肯定,它是一种适当的方式,但似乎还在发挥作用。 由于我所显示的所有数据都属于同一类别,我只使用一名阿雷拉主义者。 基本观点――详细的看法。 该团体只有一名儿童。 你们是否认为这样做了? 或者,我可能会在后来执行过程中遇到一些不一致的问题?

public ExpandableAdapter(Context context, ArrayList<VCDR> groups) {
    this.context = context;
    this.groups = groups;        
}
@Override
public Object getChild(int groupPosition, int childPosition) {

    return groups.get(groupPosition);
}

@Override
public long getChildId(int groupPosition, int childPosition) {      
    return groupPosition;
}
@Override
public int getChildrenCount(int groupPosition) {
    return 1;
}




相关问题
Android - ListView fling gesture triggers context menu

I m relatively new to Android development. I m developing an app with a ListView. I ve followed the info in #1338475 and have my app recognizing the fling gesture, but after the gesture is complete, ...

AsyncTask and error handling on Android

I m converting my code from using Handler to AsyncTask. The latter is great at what it does - asynchronous updates and handling of results in the main UI thread. What s unclear to me is how to handle ...

Android intent filter for a particular file extension?

I want to be able to download a file with a particular extension from the net, and have it passed to my application to deal with it, but I haven t been able to figure out the intent filter. The ...

Android & Web: What is the equivalent style for the web?

I am quite impressed by the workflow I follow when developing Android applications: Define a layout in an xml file and then write all the code in a code-behind style. Is there an equivalent style for ...

TiledLayer equivalent in Android [duplicate]

To draw landscapes, backgrounds with patterns etc, we used TiledLayer in J2ME. Is there an android counterpart for that. Does android provide an option to set such tiled patterns in the layout XML?

Using Repo with Msysgit

When following the Android Open Source Project instructions on installing repo for use with Git, after running the repo init command, I run into this error: /c/Users/Andrew Rabon/bin/repo: line ...

Android "single top" launch mode and onNewIntent method

I read in the Android documentation that by setting my Activity s launchMode property to singleTop OR by adding the FLAG_ACTIVITY_SINGLE_TOP flag to my Intent, that calling startActivity(intent) would ...

From Web Development to Android Development

I have pretty good skills in PHP , Mysql and Javascript for a junior developer. If I wanted to try my hand as Android Development do you think I might find it tough ? Also what new languages would I ...

热门标签