ExpandableListView SimpleExpandableListAdapter 添加数据报错

jinxuxin2009 2011-04-25 10:02:45
如题 代码如下

m_GroupData = new ArrayList<Map<String, Object>>();
m_ChildData = new ArrayList< List<Map<String, Object>>>();
m_GroupFriends = new ArrayList<List<Friend>>();
Map<String, Object> TmpGroupItem = new HashMap<String, Object>();
TmpGroupItem.put(GROUPNAME, "GroupName");
TmpGroupItem.put(GROUPSIGN, "GroupSign");
TmpGroupItem.put(GROUPHEAD, 2);
TmpGroupItem.put(NUM, "12");

m_GroupData.add(TmpGroupItem);

List<Map<String, Object>> TmpChildGroup = new ArrayList<Map<String, Object>>();

Map<String, Object> TmpChildItem = new HashMap<String, Object>();

TmpChildItem.put(NAME, "childname");
TmpChildItem.put(SIGN, "childsign");
TmpChildItem.put(HEAD, 3);
TmpChildItem.put(SCORE, "childscore");
TmpChildItem.put(TIMES, "12");

TmpChildGroup.add(TmpChildItem);

m_ChildData.add(TmpChildGroup);
m_Adapter = new SimpleExpandableListAdapter(context, m_GroupData, R.layout.groupitem,
new String[]{GROUPNAME, GROUPSIGN, GROUPHEAD, NUM},
new int[]{R.id.GroupName, R.id.GroupSiged, R.id.GroupImg, R.id.Num},
m_ChildData, R.layout.friends,
new String[]{NAME, SIGN, HEAD, SCORE, TIMES},
new int[]{R.id.Name, R.id.Siged, R.id.HeadImg, R.id.Score, R.id.SuccessTime});

this.setAdapter(m_Adapter);
groupitem.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="horizontal">
<ImageView android:id="@+id/GroupImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10px"/>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView android:id="@+id/GroupName"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#FFFFFFFF"
android:layout_weight="1"
android:textSize="22px" />
<TextView android:id="@+id/GroupSiged"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#FFFFFFFF"
android:layout_weight="2"
android:textSize="13px" />
</LinearLayout>
<TextView
android:id="@+id/Num"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="4"
/>
</LinearLayout>

friends.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal" android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ImageView android:id="@+id/HeadImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10px"/>
<LinearLayout android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<TextView android:id="@+id/Name"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#FFFFFFFF"
android:layout_weight="1"
android:textSize="22px" />
<TextView android:id="@+id/Siged"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:textColor="#FFFFFFFF"
android:layout_weight="2"
android:textSize="13px" />
</LinearLayout>
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="3"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@id/Score"
android:layout_weight="2"
/>
<TextView
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@id/SuccessTime"
android:layout_weight="2"
/>
</LinearLayout>
</LinearLayout>
...全文
250 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
zhb358254338 2012-10-19
  • 打赏
  • 举报
回复
您好,我遇到一个问题,请教SimpleExpandableListAdapter如何动态更新里面的数据,并刷新UI
jayqean 2011-04-26
  • 打赏
  • 举报
回复
XML文件里都没看到ExpandableListView的定义,代码里也没看到初始化
passself 2011-04-25
  • 打赏
  • 举报
回复
楼主报错是什么?贴出来

80,351

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧