Android ExpandableListView / ExpandableListActivity 使用及数据更新
2010-08-21 06:33:00 来源:WEB开发网View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
String string = group.get(groupPosition);
return getGenericView(string);
}
//View stub to create Group/Children 's View
public TextView getGenericView(String s) {
// Layout parameters for the ExpandableListView
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, 64);
TextView text = new TextView(activity);
text.setLayoutParams(lp);
// Center the text vertically
text.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
// Set the text starting position
text.setPadding(36, 0, 0, 0);
text.setText(s);
return text;
}
@Override
public boolean hasStableIds() {
// TODO Auto-generated method stub
return false;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition) {
// TODO Auto-generated method stub
return true;
}
}
4. emulator 运行截图:
5. 下面说一下 数据更新 问题 包括:添加数据 删除数据
* 定义添加数据界面:add.xml
Xml代码
< ?xml version="1.0" encoding="utf-8"?>
< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
< LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Tags:Android ExpandableListView ExpandableListActivity
编辑录入:coldstar [复制链接] [打 印]更多精彩
赞助商链接