WEB开发网
开发学院手机开发Android 开发 详解android 可展开(收缩)的列表ListView(Expan... 阅读

详解android 可展开(收缩)的列表ListView(ExpandableListView)

 2010-05-11 16:15:00 来源:WEB开发网   
核心提示:private List<List<String>> itemList = null;public IdeasExpandableListAdapter(Context context) {this.mContext = context;groupList = new ArrayList<

private List<List<String>> itemList = null;

public IdeasExpandableListAdapter(Context context) {

this.mContext = context;

groupList = new ArrayList<String>();

itemList = new ArrayList<List<String>>();

initData();

}

/**

* 初始化数据,将相关数据放到List中,方便处理

*/

private void initData() {

for (int i = 0; i < groups.length; i++) {

groupList.add(groups[i]);

}

List<String> item1 = new ArrayList<String>();

for (int i = 0; i < familis.length; i++) {

item1.add(familis[i]);

}

List<String> item2 = new ArrayList<String>();

for (int i = 0; i < friends.length; i++) {

item2.add(friends[i]);

}

List<String> item3 = new ArrayList<String>();

for (int i = 0; i < colleagues.length; i++) {

item3.add(colleagues[i]);

}

itemList.add(item1);

itemList.add(item2);

itemList.add(item3);

}

public boolean areAllItemsEnabled() {

return false;

}

/*

* 设置子节点对象,在事件处理时返回的对象,可存放一些数据

*/

public Object getChild(int groupPosition, int childPosition) {

return itemList.get(groupPosition).get(childPosition);

}

public long getChildId(int groupPosition, int childPosition) {

return childPosition;

}

/*

* 字节点视图,这里我们显示一个文本对象

*/

public View getChildView(int groupPosition, int childPosition,

boolean isLastChild, View convertView, ViewGroup parent) {

TextView text = null;

if (convertView == null) {

text = new TextView(mContext);

上一页  1 2 3 4  下一页

Tags:详解 android 展开

编辑录入:coldstar [复制链接] [打 印]
赞助商链接