expandablelist(expandablelistview怎么用)
本文目录
- expandablelistview怎么用
- expandablelistview和listview有什么区别
- 安卓ExpandableListView怎么使用
- expandablelistview 的hasstableids是什么意思
- 怎么实现两个expandablelistview上下放置
- android expandablelistview可以实现哪些效果
expandablelistview怎么用
ExpandableListView组件是android中一个比较常用的组件,当点击一个父item的时候可以将它的子item显示出来,像手机QQ中的好友列表就是实现的类型效果。使用ExpandableListView组件的关键就是设置它的adapter,这个adapter必须继承BaseExpandbaleListAdapter类,所以实现运用ExpandableListView的核心就是学会继承这个BaseExpanableListAdapter类。
expandablelistview和listview有什么区别
expandablelistview和listview有什么区别本例程序中,pa是一个指针数组,三个元素分别指向二维数组a的各行。然后用循环语句输出指定的数组元素。其中*a表示0行i列的值;*(p+i)表示0行i列的值。读者可仔细领会元素值的各种不同的表示方法。 应该注意指针数组和二维数组指针变量的区别。这两者虽然都可用来表示二维数组,但是其表示方法和意义是不同的。二维数组指针变量是单个的变量,其一般形式中“(*指针变量名)“两边的括号不可少。而指针数组类型表示的是多个指针(一组有序指针)在一般形式中“*指针数组名“两边不能有括号。例如: int (*p);表示一个指向二维数组的指针变量。该二维数组的列数为3或分解为一维数组的长度为3。 int *p表示p是一个指针数组,有三个下标变量p,p,p均为指针变量。指针数组也常用来表示一组字符串,这时指针数组的每个元素被赋予一个字符串的首地址。指向字符串的指针数组的初始化更为简单。例如在例10.32中即采用指针数组来表示一组字符串。其初始化赋值为: char *name={“Illagal day“,
安卓ExpandableListView怎么使用
本文实例讲述了Android中ExpandableListView的用法,ExpandableListView是android中可以实现下拉list的一个控件,具体的实现方法如下:首先:在layout的xml文件中定义一个ExpandableListView复制代码 代码如下:《LinearLayout android:id=“@+id/linearLayout“ android:layout_width=“fill_parent“ android:layout_height=“fill_parent“ androidrientation=“vertical“ 》 《ExpandableListView android:id=“@+id/expandableListView“ android:layout_width=“fill_parent“ android:layout_height=“wrap_content“ /》 《 /LinearLayout》定义两个List,用来存放控件中Group/Child中的String复制代码 代码如下:private List《String》 groupArray; private List《List《String》》 childArray;对这两个List进行初始化,并插入一些数据复制代码 代码如下:groupArray = new ArrayList《String》(); childArray = new ArrayList《List《String》》(); groupArray.add(“第一行“); groupArray.add(“第二行“); List《String》 tempArray = new ArrayList《String》(); tempArray.add(“第一条“); tempArray.add(“第二条“); tempArray.add(“第三条“); for(int index = 0; index 《groupArray.size(); ++index) { childArray.add(tempArray); }定义ExpandableListView的Adapter复制代码 代码如下://ExpandableListView的Adapter public class ExpandableAdapter extends BaseExpandableListAdapter { Activity activity; public ExpandableAdapter(Activity a) { activity = a; } public Object getChild(int groupPosition, int childPosition) { return childArray.get(groupPosition).get(childPosition); } public long getChildId(int groupPosition, int childPosition) { return childPosition; } public int getChildrenCount(int groupPosition) { return childArray.get(groupPosition).size(); } public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { String string = childArray.get(groupPosition).get(childPosition); return getGenericView(string); } // group method stub public Object getGroup(int groupPosition) { return groupArray.get(groupPosition); } public int getGroupCount() { return groupArray.size(); } public long getGroupId(int groupPosition) { return groupPosition; } public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { String string = groupArray.get(groupPosition); return getGenericView(string); } // View stub to create Group/Children ’s View public TextView getGenericView(String string) { // Layout parameters for the ExpandableListView AbsListView.LayoutParams layoutParams = new AbsListView.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, 64); TextView text = new TextView(activity); text.setLayoutParams(layoutParams); // Center the text vertically text.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); // Set the text starting position text.setPadding(36, 0, 0, 0); text.setText(string); return text; } public boolean hasStableIds() { return false; } public boolean isChildSelectable(int groupPosition, int childPosition) { return true; } }最后,给定义好的ExpandableListView添加上Adapter
expandablelistview 的hasstableids是什么意思
ExpandableListView的适配器继承BaseExpandableListAdapter其中有一个重载方法是hasStableIds()has 有 Stable 稳定的 Ids 多个ID 作用是:是否指定分组视图及其子视图的ID对应的后台数据改变也会保持该ID通俗点:如果return ture,后台数据变了,id也不会变备注:个人理解,有误,请回复
怎么实现两个expandablelistview上下放置
Android中ExpandableListView的使用ExpandableListView是android中可以实现下拉list的一个控件,具体的实现方法如下:首先:在layout的xml文件中定义一个ExpandableListViewviewplaincopytoclipboardprint?定义两个List,用来存放控件中Group/Child中的Stringviewplaincopytoclipboardprint?privateListgroupArray;privateList》childArray;对这两个List进行初始化,并插入一些数据viewplaincopytoclipboardprint?groupArray=newArrayList();childArray=newArrayList》();groupArray.add(“第一行“);groupArray.add(“第二行“);ListtempArray=newArrayList();tempArray.add(“第一条“);tempArray.add(“第二条“);tempArray.add(“第三条“);for(intindex=0;index
android expandablelistview可以实现哪些效果
Android中ExpandableListView的使用ExpandableListView是android中可以实现下拉list的一个控件,具体的实现方法如下:首先:在layout的xml文件中定义一个ExpandableListViewview plain copy to clipboard print ?《 LinearLayout android:id =“@+id/linearLayout“ android:layout_width =“fill_parent“ android:layout_height =“fill_parent“ androidrientation =“vertical“ 》 《 ExpandableListView android:id =“@+id/expandableListView“ android:layout_width =“fill_parent“ android:layout_height =“wrap_content“ /》 《/ LinearLayout 》 定义两个List,用来存放控件中Group/Child中的Stringview plain copy to clipboard print ?private List《String》 groupArray; private List《List《String》》 childArray; 对这两个List进行初始化,并插入一些数据view plain copy to clipboard print ?groupArray = new ArrayList《String》(); childArray = new ArrayList《List《String》》(); groupArray.add(“第一行“ ); groupArray.add(“第二行“ ); List《String》 tempArray = new ArrayList《String》(); tempArray.add(“第一条“ ); tempArray.add(“第二条“ ); tempArray.add(“第三条“ ); for (int index = 0 ; index 《groupArray.size(); ++index) { childArray.add(tempArray); } 定义ExpandableListView的Adapterview plain copy to clipboard print ?//ExpandableListView的Adapter public class ExpandableAdapter extends BaseExpandableListAdapter { Activity activity; public ExpandableAdapter(Activity a) { activity = a; } public Object getChild(int groupPosition, int childPosition) { return childArray.get(groupPosition).get(childPosition); } public long getChildId(int groupPosition, int childPosition) { return childPosition; } public int getChildrenCount(int groupPosition) { return childArray.get(groupPosition).size(); } public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { String string = childArray.get(groupPosition).get(childPosition); return getGenericView(string); } // group method stub public Object getGroup(int groupPosition) { return groupArray.get(groupPosition); } public int getGroupCount() { return groupArray.size(); } public long getGroupId(int groupPosition) { return groupPosition; } public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { String string = groupArray.get(groupPosition); return getGenericView(string); } // View stub to create Group/Children ’s View public TextView getGenericView(String string) { // Layout parameters for the ExpandableListView AbsListView.LayoutParams layoutParams = new AbsListView.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, 64 ); TextView text = new TextView(activity); text.setLayoutParams(layoutParams); // Center the text vertically text.setGravity(Gravity.CENTER_VERTICAL | Gravity.LEFT); // Set the text starting position text.setPadding(36 , 0 , 0 , 0 ); text.setText(string); return text; } public boolean hasStableIds() { return false ; } public boolean isChildSelectable(int groupPosition, int childPosition) { return true ; } } 最后,给定义好的ExpandableListView添加上Adapterview plain copy to clipboard print ?ExpandableListView expandableListView = (ExpandableListView)findViewById(R.id.expandableListView); expandableListView.setAdapter(new ExpandableAdapter(Main.this )); 运行即可见效果~~~
更多文章:

java从入门到精通第4版(java从入门到精通,有哪些书籍和视频适合学习)
2025年3月16日 15:30

计算机网络第七版谢希仁课后答案(计算机网络谢希仁编著的第六版第四章课后习题答案)
2025年4月18日 14:20

瀑布流布局的原理及实现(css的发展历史和设计原理是怎样的)
2025年3月5日 13:00

getproperty什么意思(flash getproperty 什么意思)
2025年4月18日 00:00

shut down什么意思(shutdown -s -t都是什么意思)
2025年3月7日 01:50

network error怎么解决(每次打开某些网站都出现这个:Network Error (tcp_error) 怎么解决)
2025年3月10日 02:50

thymeleaf(spring为什么要推荐使用thymeleaf)
2025年4月14日 23:40

precedent的意思(take precedent是什么意思)
2025年4月5日 22:10