android ExpandableListActivity 练习
来源:互联网 发布:js div绑定click事件 编辑:程序博客网 时间:2024/05/16 17:36
不足之处请多多指正,共同学习
public class MainActivity extends ExpandableListActivity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); ExpandableListAdapter adapter = new ExpandableListAdapter() { String[] groups = new String[] { "神族兵种", "虫族兵种", "人族兵种"}; String[][] child = new String[][] { { "狂战士", "龙骑士", "黑暗圣堂", "电兵" }, { "小狗", "刺蛇", "飞龙", "自爆飞机" }, { "机枪兵", "护士MM" , "幽灵" } }; @Override public void registerDataSetObserver(DataSetObserver observer) { } @Override public void unregisterDataSetObserver(DataSetObserver observer) { } @Override public int getGroupCount() { return groups.length; } @Override public int getChildrenCount(int groupPosition) { return child[groupPosition].length; } @Override public Object getGroup(int groupPosition) { return groups[groupPosition]; } @Override public Object getChild(int groupPosition, int childPosition) { return child[groupPosition][childPosition]; } @Override public long getGroupId(int groupPosition) { return groupPosition; } @Override public long getChildId(int groupPosition, int childPosition) { return childPosition; } @Override public boolean hasStableIds() { return true; } @Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { TextView v; if (convertView == null){ v = new TextView(MainActivity.this); v.setPadding(45,0,0,0); v.setTextSize(20); }else{ v = (TextView) convertView; } v.setText(groups[groupPosition]); return v; } @Override public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { TextView v; if (convertView == null){ v = new TextView(MainActivity.this); v.setPadding(60,0,0,0); v.setTextSize(15); }else{ v = (TextView) convertView; } v.setText(child[groupPosition][childPosition]); return v; } @Override public boolean isChildSelectable(int groupPosition, int childPosition) { return true; } @Override public boolean areAllItemsEnabled() { return true; } @Override public boolean isEmpty() { return false; } @Override public void onGroupExpanded(int groupPosition) { //选项组展开 } @Override public void onGroupCollapsed(int groupPosition) { //选项组折叠 } @Override public long getCombinedChildId(long groupId, long childId) { return childId; } @Override public long getCombinedGroupId(long groupId) { return groupId; } }; setListAdapter(adapter); }}
0 0
- android ExpandableListActivity 练习
- Android-ExpandableListActivity
- android ExpandableListActivity
- Android UI ExpandableListActivity与ExpandableListActivity
- Android ExpandableListActivity 学习笔记
- Android ExpandableListActivity 学习笔记
- Android基础之ExpandableListActivity
- [Android] ExpandableListActivity的使用
- Android开发--浅谈ExpandableListActivity
- (android 基础知识) ExpandableListActivity
- android ExpandableListActivity简介
- Android基础之ExpandableListActivity
- android之ExpandableListActivity
- Android开发之ExpandableListActivity
- Android LauncherActivity,ExpandableListActivity,PreferenceActivity
- ExpandableListActivity
- ExpandableListActivity
- ExpandableListActivity
- Hadoop入门基础知识[2]-运行原理
- uiview关联xib
- Palette颜色提取使用详解
- The Giver
- vim 配置 部分相关内容
- android ExpandableListActivity 练习
- Word转换Html后分页展示--第一部分
- Android(2)——项目目录结构详解
- 纯CSS3实现的蜘蛛爬行动画
- java反射技术
- wegwg
- 对C++中指针做函数形参的理解
- 【思维导图】数据结构第五章 树和二叉树
- android Notification 的使用