- 浏览: 684318 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
Hippyqq:
谢谢很有用,
java中遍历MAP的几种方法 -
XSoftlab:
超详细。。。Java map 详解 - 用法、遍历、排序、常用 ...
java中遍历MAP的几种方法 -
bobo22:
importnet.sf.fmj.ui.application ...
java来调用电脑视频摄像头拍照进行截图 -
qq981378640:
#include <stdio.h>
int ...
c语言中unsigned类型和普通类型间的转换 -
qq981378640:
楼主你这样有点复杂了,直接这样写更好更方便
#include ...
c语言中unsigned类型和普通类型间的转换
An activity that displays an expandable list of items by binding to a data source implementing the ExpandableListAdapter, and exposes event handlers when the user selects an item.
即,可扩展的list,单击某个item后,又可显示一个子list。它的数据通过绑定到ExpandableListAdapter或者ExpandableListAdapter的子类上。
示例1—通过SimpelExpandableListAdapter绑定数据:
view plaincopy to clipboardprint?
public class ExpandableList3 extends ExpandableListActivity {
private static final String NAME = "NAME";
private static final String IS_EVEN = "IS_EVEN";
private ExpandableListAdapter mAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
for (int i = 0; i < 20; i++) {
Map<String, String> curGroupMap = new HashMap<String, String>();
groupData.add(curGroupMap);
curGroupMap.put(NAME, "Group " + i);
curGroupMap.put(IS_EVEN, (i % 2 == 0) ? "This group is even" : "This group is odd");
List<Map<String, String>> children = new ArrayList<Map<String, String>>();
for (int j = 0; j < 15; j++) {
Map<String, String> curChildMap = new HashMap<String, String>();
children.add(curChildMap);
curChildMap.put(NAME, "Child " + j);
curChildMap.put(IS_EVEN, (j % 2 == 0) ? "This child is even" : "This child is odd");
}
childData.add(children);
}
// Set up our adapter
mAdapter = new SimpleExpandableListAdapter(
this,
groupData, // 存储父list的数据
android.R.layout.simple_expandable_list_item_2, //父list的现实方式
new String[] { NAME,IS_EVEN}, // 父list需要显示的数据
new int[] { android.R.id.text1,android.R.id.text2}, // 父list的数据绑定到的view
childData, //子list的数据
android.R.layout.simple_expandable_list_item_2,
new String[] { NAME, IS_EVEN },
new int[] { android.R.id.text1, android.R.id.text2 }
);
setListAdapter(mAdapter);
}
}
注意:android.R.layout.simple_expandable_list_item_1:表示只显示一个TextView的数据,即R.id.text1
android.R.layout.simple_expandable_list_item_2:表示显示二个TextView的数据,即R.id.text1,R.id,text2
android.R.layout.simple_expandable_list_item_2.xml(在R.layout中)文件的布局如下:
view plaincopy to clipboardprint?
<?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="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/text1"
android:textSize="16sp"
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/text2"
android:textSize="16sp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
示例2—通过SimpleCussorTreeAdapter绑定数据:
view plaincopy to clipboardprint?
public class ExpandableList2 extends ExpandableListActivity {
private int mGroupIdColumnIndex;
private String mPhoneNumberProjection[] = new String[] {
People.Phones._ID, People.Phones.NUMBER
};
private ExpandableListAdapter mAdapter;
/*
* CursorTreeAdapter's method.
* Gets the Cursor for the children at the given group
* /
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Query for people
Cursor groupCursor = managedQuery(People.CONTENT_URI,
new String[] {People._ID, People.NAME}, null, null, null);
// Cache the ID column index
mGroupIdColumnIndex = groupCursor.getColumnIndexOrThrow(People._ID);
// Set up our adapter
mAdapter = new MyExpandableListAdapter(groupCursor,
this,
android.R.layout.simple_expandable_list_item_1,
android.R.layout.simple_expandable_list_item_1,
new String[] {People.NAME}, // Name for group layouts
new int[] {android.R.id.text1},
new String[] {People.NUMBER}, // Number for child layouts
new int[] {android.R.id.text1});
setListAdapter(mAdapter);
}
public class MyExpandableListAdapter extends SimpleCursorTreeAdapter {
public MyExpandableListAdapter(Cursor cursor, Context context, int groupLayout,
int childLayout, String[] groupFrom, int[] groupTo, String[] childrenFrom,
int[] childrenTo) {
super(context, cursor, groupLayout, groupFrom, groupTo, childLayout, childrenFrom,
childrenTo);
}
@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
// Given the group, we return a cursor for all the children within that group
// Return a cursor that points to this contact's phone numbers
Uri.Builder builder = People.CONTENT_URI.buildUpon();
ContentUris.appendId(builder, groupCursor.getLong(mGroupIdColumnIndex));
builder.appendEncodedPath(People.Phones.CONTENT_DIRECTORY);
Uri phoneNumbersUri = builder.build();
// The returned Cursor MUST be managed by us, so we use Activity's helper
// functionality to manage it for us.
return managedQuery(phoneNumbersUri, mPhoneNumberProjection, null, null, null);
}
}
}
示例3—通过BaseExpandableListAdapter绑定数据:
view plaincopy to clipboardprint?
public class ExpandableList1 extends ExpandableListActivity {
ExpandableListAdapter mAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set up our adapter
mAdapter = new MyExpandableListAdapter();
setListAdapter(mAdapter);
// register context menu, when long click the item, it will show a dialog
registerForContextMenu(getExpandableListView());
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
menu.setHeaderTitle("Sample menu");
menu.add(0, 0, 0, R.string.expandable_list_sample_action);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
String title = ((TextView) info.targetView).getText().toString();
int type = ExpandableListView.getPackedPositionType(info.packedPosition);
if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
int childPos = ExpandableListView.getPackedPositionChild(info.packedPosition);
Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos,
Toast.LENGTH_SHORT).show();
return true;
} else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
return true;
}
return false;
}
/**
* A simple adapter which maintains an ArrayList of photo resource Ids.
* Each photo is displayed as an image. This adapter supports clearing the
* list of photos and adding a new photo.
*
*/
public class MyExpandableListAdapter extends BaseExpandableListAdapter {
// Sample data set. children[i] contains the children (String[]) for groups[i].
private String[] groups = { "People Names", "Dog Names", "Cat Names", "Fish Names" };
private String[][] children = {
{ "Arnold", "Barry", "Chuck", "David" },
{ "Ace", "Bandit", "Cha-Cha", "Deuce" },
{ "Fluffy", "Snuggles" },
{ "Goldy", "Bubbles" }
};
public Object getChild(int groupPosition, int childPosition) {
return children[groupPosition][childPosition];
}
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
public int getChildrenCount(int groupPosition) {
return children[groupPosition].length;
}
public TextView getGenericView() {
// Layout parameters for the ExpandableListView
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, 64);
TextView textView = new TextView(ExpandableList1.this);
textView.setLayoutParams(lp);
// Center the text vertically
textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
// Set the text starting position
textView.setPadding(36, 0, 0, 0);
return textView;
}
public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
View convertView, ViewGroup parent) {
TextView textView = getGenericView();
textView.setText(getChild(groupPosition, childPosition).toString());
return textView;
}
public Object getGroup(int groupPosition) {
return groups[groupPosition];
}
public int getGroupCount() {
return groups.length;
}
public long getGroupId(int groupPosition) {
return groupPosition;
}
public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
ViewGroup parent) {
TextView textView = getGenericView();
textView.setText(getGroup(groupPosition).toString());
return textView;
}
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
public boolean hasStableIds() {
return true;
}
}
} 来自http://blog.csdn.net/xiangyong2008/archive/2010/03/06/5351969.aspx
即,可扩展的list,单击某个item后,又可显示一个子list。它的数据通过绑定到ExpandableListAdapter或者ExpandableListAdapter的子类上。
示例1—通过SimpelExpandableListAdapter绑定数据:
view plaincopy to clipboardprint?
public class ExpandableList3 extends ExpandableListActivity {
private static final String NAME = "NAME";
private static final String IS_EVEN = "IS_EVEN";
private ExpandableListAdapter mAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
List<Map<String, String>> groupData = new ArrayList<Map<String, String>>();
List<List<Map<String, String>>> childData = new ArrayList<List<Map<String, String>>>();
for (int i = 0; i < 20; i++) {
Map<String, String> curGroupMap = new HashMap<String, String>();
groupData.add(curGroupMap);
curGroupMap.put(NAME, "Group " + i);
curGroupMap.put(IS_EVEN, (i % 2 == 0) ? "This group is even" : "This group is odd");
List<Map<String, String>> children = new ArrayList<Map<String, String>>();
for (int j = 0; j < 15; j++) {
Map<String, String> curChildMap = new HashMap<String, String>();
children.add(curChildMap);
curChildMap.put(NAME, "Child " + j);
curChildMap.put(IS_EVEN, (j % 2 == 0) ? "This child is even" : "This child is odd");
}
childData.add(children);
}
// Set up our adapter
mAdapter = new SimpleExpandableListAdapter(
this,
groupData, // 存储父list的数据
android.R.layout.simple_expandable_list_item_2, //父list的现实方式
new String[] { NAME,IS_EVEN}, // 父list需要显示的数据
new int[] { android.R.id.text1,android.R.id.text2}, // 父list的数据绑定到的view
childData, //子list的数据
android.R.layout.simple_expandable_list_item_2,
new String[] { NAME, IS_EVEN },
new int[] { android.R.id.text1, android.R.id.text2 }
);
setListAdapter(mAdapter);
}
}
注意:android.R.layout.simple_expandable_list_item_1:表示只显示一个TextView的数据,即R.id.text1
android.R.layout.simple_expandable_list_item_2:表示显示二个TextView的数据,即R.id.text1,R.id,text2
android.R.layout.simple_expandable_list_item_2.xml(在R.layout中)文件的布局如下:
view plaincopy to clipboardprint?
<?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="wrap_content"
android:orientation="vertical">
<TextView android:id="@+id/text1"
android:textSize="16sp"
android:textStyle="bold"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
<TextView android:id="@+id/text2"
android:textSize="16sp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"/>
</LinearLayout>
示例2—通过SimpleCussorTreeAdapter绑定数据:
view plaincopy to clipboardprint?
public class ExpandableList2 extends ExpandableListActivity {
private int mGroupIdColumnIndex;
private String mPhoneNumberProjection[] = new String[] {
People.Phones._ID, People.Phones.NUMBER
};
private ExpandableListAdapter mAdapter;
/*
* CursorTreeAdapter's method.
* Gets the Cursor for the children at the given group
* /
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Query for people
Cursor groupCursor = managedQuery(People.CONTENT_URI,
new String[] {People._ID, People.NAME}, null, null, null);
// Cache the ID column index
mGroupIdColumnIndex = groupCursor.getColumnIndexOrThrow(People._ID);
// Set up our adapter
mAdapter = new MyExpandableListAdapter(groupCursor,
this,
android.R.layout.simple_expandable_list_item_1,
android.R.layout.simple_expandable_list_item_1,
new String[] {People.NAME}, // Name for group layouts
new int[] {android.R.id.text1},
new String[] {People.NUMBER}, // Number for child layouts
new int[] {android.R.id.text1});
setListAdapter(mAdapter);
}
public class MyExpandableListAdapter extends SimpleCursorTreeAdapter {
public MyExpandableListAdapter(Cursor cursor, Context context, int groupLayout,
int childLayout, String[] groupFrom, int[] groupTo, String[] childrenFrom,
int[] childrenTo) {
super(context, cursor, groupLayout, groupFrom, groupTo, childLayout, childrenFrom,
childrenTo);
}
@Override
protected Cursor getChildrenCursor(Cursor groupCursor) {
// Given the group, we return a cursor for all the children within that group
// Return a cursor that points to this contact's phone numbers
Uri.Builder builder = People.CONTENT_URI.buildUpon();
ContentUris.appendId(builder, groupCursor.getLong(mGroupIdColumnIndex));
builder.appendEncodedPath(People.Phones.CONTENT_DIRECTORY);
Uri phoneNumbersUri = builder.build();
// The returned Cursor MUST be managed by us, so we use Activity's helper
// functionality to manage it for us.
return managedQuery(phoneNumbersUri, mPhoneNumberProjection, null, null, null);
}
}
}
示例3—通过BaseExpandableListAdapter绑定数据:
view plaincopy to clipboardprint?
public class ExpandableList1 extends ExpandableListActivity {
ExpandableListAdapter mAdapter;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set up our adapter
mAdapter = new MyExpandableListAdapter();
setListAdapter(mAdapter);
// register context menu, when long click the item, it will show a dialog
registerForContextMenu(getExpandableListView());
}
@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
menu.setHeaderTitle("Sample menu");
menu.add(0, 0, 0, R.string.expandable_list_sample_action);
}
@Override
public boolean onContextItemSelected(MenuItem item) {
ExpandableListContextMenuInfo info = (ExpandableListContextMenuInfo) item.getMenuInfo();
String title = ((TextView) info.targetView).getText().toString();
int type = ExpandableListView.getPackedPositionType(info.packedPosition);
if (type == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
int childPos = ExpandableListView.getPackedPositionChild(info.packedPosition);
Toast.makeText(this, title + ": Child " + childPos + " clicked in group " + groupPos,
Toast.LENGTH_SHORT).show();
return true;
} else if (type == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
int groupPos = ExpandableListView.getPackedPositionGroup(info.packedPosition);
Toast.makeText(this, title + ": Group " + groupPos + " clicked", Toast.LENGTH_SHORT).show();
return true;
}
return false;
}
/**
* A simple adapter which maintains an ArrayList of photo resource Ids.
* Each photo is displayed as an image. This adapter supports clearing the
* list of photos and adding a new photo.
*
*/
public class MyExpandableListAdapter extends BaseExpandableListAdapter {
// Sample data set. children[i] contains the children (String[]) for groups[i].
private String[] groups = { "People Names", "Dog Names", "Cat Names", "Fish Names" };
private String[][] children = {
{ "Arnold", "Barry", "Chuck", "David" },
{ "Ace", "Bandit", "Cha-Cha", "Deuce" },
{ "Fluffy", "Snuggles" },
{ "Goldy", "Bubbles" }
};
public Object getChild(int groupPosition, int childPosition) {
return children[groupPosition][childPosition];
}
public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}
public int getChildrenCount(int groupPosition) {
return children[groupPosition].length;
}
public TextView getGenericView() {
// Layout parameters for the ExpandableListView
AbsListView.LayoutParams lp = new AbsListView.LayoutParams(
ViewGroup.LayoutParams.FILL_PARENT, 64);
TextView textView = new TextView(ExpandableList1.this);
textView.setLayoutParams(lp);
// Center the text vertically
textView.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT);
// Set the text starting position
textView.setPadding(36, 0, 0, 0);
return textView;
}
public View getChildView(int groupPosition, int childPosition, boolean isLastChild,
View convertView, ViewGroup parent) {
TextView textView = getGenericView();
textView.setText(getChild(groupPosition, childPosition).toString());
return textView;
}
public Object getGroup(int groupPosition) {
return groups[groupPosition];
}
public int getGroupCount() {
return groups.length;
}
public long getGroupId(int groupPosition) {
return groupPosition;
}
public View getGroupView(int groupPosition, boolean isExpanded, View convertView,
ViewGroup parent) {
TextView textView = getGenericView();
textView.setText(getGroup(groupPosition).toString());
return textView;
}
public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}
public boolean hasStableIds() {
return true;
}
}
} 来自http://blog.csdn.net/xiangyong2008/archive/2010/03/06/5351969.aspx
发表评论
-
android应用 获取本地指定类型文件 的两种最优方法
2013-04-07 16:29 14159刚因为项目有需求,需求移动应用获取本地文件有下面两个 第一个 ... -
android 滚动条
2011-01-17 14:05 2114在ListView中添加属性: android:scrollb ... -
LayoutInflater的使用 android
2010-10-28 15:54 1175在实际开发种LayoutInflater这个类还是非常有用的, ... -
Android虚拟机大屏幕设置(开发平板电脑程序)
2010-08-31 10:33 2977如果使用android进行大屏幕开发,比如开发基于androi ... -
adb shell下使用命令行删除android系统中指定文件和文件夹
2010-08-25 13:07 26328记录一下命令: tools>adb remount t ... -
Android permission 访问权限大全
2010-07-30 23:03 1160androidmanifest.xml中声明相关权限请求, 完 ... -
android实现底部菜单栏
2010-07-29 15:56 7169android程序,许多时候需要菜单栏显示在底部或顶部,但是没 ... -
[转]android animation的应用实例
2010-07-20 23:13 1852此文件名为myanimation.xml 位于 res/ani ... -
Android入门第八篇之GridView(九宫图)
2010-07-15 17:32 2544GridView更是实现九宫图的首选!本文就是介绍如何使用Gr ... -
Android入门第五篇之TableLayout (二)//生成10行,8列的表格
2010-07-15 14:02 4182TableLayout添加数据(9宫图也可以用TableLay ... -
Android工具之Hierarchy Viewer--分析应用程序UI布局
2010-07-14 23:37 3689Android SDK提供的Hierarchy Viewer工 ... -
apk打包
2010-07-14 23:27 10404什么是apk文件 APK是Android Package Ki ... -
Android Intent的几种用法全面总结
2010-07-14 18:05 1183Intent, 用法 Intent应该算是Android中特有 ... -
进度条(ProgressBar)拖动条(SeekBar)android
2010-07-12 17:28 16772本文源自http://www.cnblogs.com/Terr ... -
TextView 在xml文件中的解释 android
2010-07-11 19:27 6870包位置:android.widget.TextView X ... -
Activity的跳转与传值
2010-07-05 16:54 3212Activity跳转与传值,主要是通过Intent类来连接多个 ... -
android:属性 layout_alignParentRight android:paddingRight
2010-07-03 22:59 11539android:layout_alignParentRight ... -
android模拟器输入中文
2010-06-29 16:50 2813首先:在设置里,选区域和文本,里面把谷歌拼音输入法复选上,就o ... -
Android Map开发基础知识学习笔记
2010-06-29 11:14 3466注册 Android 地图 API 密钥 运行:keyto ... -
Android MapView 申请apiKey
2010-06-29 11:01 13031. 首先先要获取你的debug keystore位置: 打开 ...
相关推荐
`ExpandableListActivity`是Android开发中的一个关键组件,它属于`ListView`的扩展,能够显示可折叠的子列表项,使得用户界面更加有层次感和交互性。在这个主题下,我们将深入探讨`ExpandableListActivity`的工作...
通过这个例子,开发者可以学习到如何在Android应用中使用`ExpandableListActivity`展示层次结构数据,并通过`Handler`实现动画效果。这在展示具有多级分类的数据时非常有用,例如日历应用的月份和日期、菜单的分类和...
本篇笔记将深入探讨如何使用ExpandableListView,以及如何用HashMap作为数据源。 首先,ExpandableListView的核心在于它的数据模型,它由两部分组成:Groups(父项)和Childrens(子项)。每个Group可以包含多个...
`ExpandableListActivity`是Android框架中用于显示层次结构数据的Activity。与传统的`ListActivity`不同,它能够展示多层级的数据,即可以有父项和子项的概念。用户可以通过点击父项来展开或折叠其子项列表,非常...
本笔记集合了"Mars Android视频教程"的主要知识点,旨在帮助学习者回顾和巩固课程中的核心概念。以下是根据文件名整理出的各章节内容详解: 1. **Animations.doc** - 动画是Android应用中提升用户体验的关键元素。...
### Android开发笔记知识点详解 #### 第1章 Android简介 **1.1 Android与iPhone** - **Android**: 是一种基于Linux内核(不包含GNU组件)的自由及开放源代码的操作系统,主要使用于移动设备,如智能手机和平板...
### Android 安卓笔记知识点详解 #### Android—基础 ##### 基础—概念 - **控件类之父**:`View`是所有控件的基类,无论是简单的按钮还是复杂的列表视图,都是从这个类派生出来的。 - **基准线**:在英文书写中,...
PreferenceActivity和ExpandableListActivity的使用,详细了解请移步:http://blog.csdn.net/zxc514257857/article/details/77773001
* @see android.app.ExpandableListActivity#onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo) */ @Override public void onCreateContextMenu...
import android.app.ExpandableListActivity; import android.os.Bundle; public class MainActivity extends ExpandableListActivity { @Override protected void onCreate(Bundle savedInstanceState) { super...
在Android中,我们可以使用`ExpandableListActivity`或者普通的`Activity`配合`ExpandableListView`进行布局。数据通常由`ExpandableListAdapter`管理,这个适配器需要实现`BaseExpandableListAdapter`接口。 在...
Android控件下拉框,单选按钮,复选框,自动补全,日期控件(支持显示格式:年月,年月日,月日),LauncherActivity的使用,ExpandableListActivity实现二级下拉列表,并且在列表项右边加自定义的图片,实现只展开一个菜单的功能...
`ExpandableListView`通常与`ExpandableListActivity`一起使用,就像`ListActivity`与`ListView`的关系一样。 首先,我们需要创建一个包含`ExpandableListView`的布局。在`main.xml`中,你可以看到以下代码: ```...
在我们的示例代码中,我们创建了一个 ActivityMain 类,该类继承自 ExpandableListActivity,并实现了 onCreate()、onCreateContextMenu() 和 onContextItemSelected() 等方法。这些方法负责初始化列表控件、创建上...
在Android应用开发中,`ExpandableListView`是一个非常有用的控件,它允许用户展示一个可折叠/展开的列表,这种列表通常用于显示层次结构的数据,如目录结构、菜单或者RSS阅读器中的文章分类。在这个例子中,我们...
在Android开发中,ExpandableListView是一个非常重要的控件,它允许用户展示数据集,并且以可...这不仅涉及到基本的UI布局,还涵盖了数据处理、事件监听和性能优化等多个方面,对于Android应用开发有着重要的学习价值。
在Android应用开发中,创建一个个人理财工具是一个实用且具有挑战性的任务。本文将探讨如何在这样的工具中实现添加账单页面,这是一个关键功能,允许用户记录他们的收入和支出。在这一部分,我们将关注界面设计、...
在Android开发中,`ExpandableListView` 是一个非常实用的控件,它可以显示具有扩展功能的列表,即每个条目可以展开以显示更多的子条目,通常用于构建具有层级结构的数据展示。本教程将深入讲解如何在Android应用中...
接下来是关键的Java代码,通常继承自`ExpandableListActivity`或者自定义的`BaseExpandableListAdapter`。这里,`ExpandActivity`类负责设置`ExpandableListView`的数据源和适配器。`onCreate`方法是初始化的关键点...
(2)第二种方法则是创建一个Activity继承自ExpandableListActivity,而后通过getExpandableListView()方法可获得一个ExpandableListView对象。 第二种方法仅适用于一个页面中只有一个ExpandableListView的情况。...