代码可以正常运行,没有任何错误或警告,但可扩展列表未显示,这是代码

public class MainActivity extends Activity implements ExpandableListView.OnChildClickListener{

ArrayList childitems;

ArrayList groupitems;

ExpandableListView list;

@Override

protected void onCreate(Bundle savedInstanceState) {

setContentView(R.layout.activity_main);

list=(ExpandableListView)findViewById(R.id.list);

list.setOnChildClickListener(this);

addGroupItems();

addChildItems();

LayoutInflater inflater=(LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);

ExpandableListAdapterImpl adapter=new ExpandableListAdapterImpl(inflater, this, groupitems, childitems);

list.setAdapter(adapter);

super.onCreate(savedInstanceState);

}

private void addChildItems() {

ArrayList childlist;

try {

childitems=new ArrayList();

childlist=new ArrayList();

childlist.add("Pragnani");

childlist.add("Kinnera");

childlist.add("Good");

childitems.add(childlist);

childlist=new ArrayList();

childlist.add("Bannu");

childlist.add("Kinnera");

childlist.add("Good");

childitems.add(childlist);

} catch (Exception e) {

e.printStackTrace();

}

}

private void addGroupItems() {

try {

groupitems=new ArrayList();

groupitems.add("My Details 1");

groupitems.add("My Details 2");

} catch (Exception e) {

e.printStackTrace();

}

}

@Override

public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {

// TODO Auto-generated method stub

return false;

}

}

这是activity_main.xml

xmlns:tools="http://schemas.android.com/tools"

android:layout_width="match_parent"

android:layout_height="match_parent"

tools:context=".MainActivity" >

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:id="@+id/list"

>

可扩展列表视图适配器实现

public class ExpandableListAdapterImpl extends BaseExpandableListAdapter

{

LayoutInflater inflatter;

Context context;

ArrayList groupitems;

ArrayList childitems;

ExpandableListAdapterImpl(LayoutInflater inflater,Activity activity,ArrayList groupitems,ArrayList childitems)

{

super();

this.inflatter=inflater;

context=activity;

this.groupitems=groupitems;

this.childitems=childitems;

}

@Override

public Object getChild(int groupPosition, int childPosition) {

// TODO Auto-generated method stub

return null;

}

@Override

public long getChildId(int groupPosition, int childPosition) {

// TODO Auto-generated method stub

return 0;

}

@Override

public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {

ArrayList childtemp=(ArrayList) childitems.get(groupPosition);

try {

if(convertView==null)

{

convertView=inflatter.inflate(R.layout.childrow, null);

}

Button button=(Button)convertView.findViewById(R.id.button1);

button.setText(childtemp.get(groupPosition).toString());

} catch (Exception e) {

e.printStackTrace();

}

return convertView;

}

@Override

public int getChildrenCount(int groupPosition) {

// TODO Auto-generated method stub

return 0;

}

@Override

public Object getGroup(int groupPosition) {

// TODO Auto-generated method stub

return null;

}

@Override

public int getGroupCount() {

// TODO Auto-generated method stub

return 0;

}

@Override

public long getGroupId(int groupPosition) {

// TODO Auto-generated method stub

return 0;

}

@Override

public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {

try {

if(convertView==null)

{

convertView=inflatter.inflate(R.layout.grouprow, null);

}

CheckedTextView view=(CheckedTextView) convertView.findViewById(R.id.textView1);

view.setText(groupitems.get(groupPosition).toString());

view.setChecked(isExpanded);

} catch (Exception e) {

e.printStackTrace();

}

return convertView;

}

@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 false;

}

}

这是grouprow.xml

xmlns:android="http://schemas.android.com/apk/res/android"

android:id="@+id/textView1"

android:layout_width="wrap_content"

android:layout_height="60dp"

android:layout_marginLeft="5dp"

android:drawableRight="@drawable/plusminus"

android:gravity="center_vertical"

android:padding="10dp"

android:text="@string/hello_world"

android:textColor="#FFFFFF"

android:textSelectHandleLeft="@string/hello_world"

android:textSize="14sp"

android:textStyle="bold" />

childrow.xml

android:layout_width="match_parent"

android:layout_height="match_parent"

android:orientation="vertical" >

android:id="@+id/button1"

android:background="@drawable/playersdetails"

android:layout_width="wrap_content"

android:layout_height="wrap_content"

android:text="" />

我想知道我想念的地方…在此先感谢

android可扩展列表,android-可扩展列表视图未显示相关推荐

  1. android usb单反相机,在Android应用程序上使用USB Camera

    只有当USB相机中的传感器符合UVC标准(今天的大多数相机都符合)时,讨论才成立. 默认情况下,没有Android API可用于外部摄像头.所以如果你对这个项目很认真,那么你所做的工作就是编写一个与内 ...

  2. android可扩展列表,android ExpandableListView可扩展列表

    http://leiwuluan.iteye.com/blog/1508356 先看一效果图. 列表中要有 图片和文字: 所以我们要实现一个自定义的   适配器. 介绍一个类:BaseExpandab ...

  3. 利用Adobe AIR本地扩展支持Android开发

    http://bbs.9ria.com/thread-180609-1-1.html 学前准备... 2 所需知识... 2 额外工具... 2 用户等级... 2 例子文件... 2 设置AIR S ...

  4. Android使用RecyclerView实现仿微信联系人列表

    现在联系人列表基本都是按照字母或者拼音来进行分类,右边有一排字母供用户快速定位到指定的字母位置,效果图如下: OK,输入的联系人类型可能有很多种,比如汉字.英文.数字.特殊符号等等,其中汉字会转化成拼 ...

  5. android 图片大小判断,Android列表查看图片大小

    我的列表视图中有一个问题,它包含一个ImageView和每个项目的几个TextView.Android列表查看图片大小 更多或更少的,有TextViews的两条线和一个ImageView的(XX)应该 ...

  6. android 二级折叠列表,Android折叠列表 ExpandableList

    ExpandableList 是折叠列表,通过继承ExpandableListActivity 类就可以非常简单的实现折叠列表. 效果图: 代码实现 package com.zhou.activity ...

  7. Android应用的权限配置和权限列表(仅供参考)

    Android开发需要在manifest 中添加常用需要的权限,列如下方一个manifest 文件,现将权限列表展示,仅供参考. <?xml version="1.0" en ...

  8. Android UI开发第五篇——自定义列表

    自定义列表,设置列表背景.列表的列背景.列表的间隔线. 借鉴了一些前辈的代码. MainActivity.class public class MainActivity extends Activit ...

  9. android碎片功能实现,Android 列表碎片

    Android 列表碎片 列表碎片的基本实现是用来在碎片中创建项目列表 实例 这个实例解释如何基于 ArrayAdapter 来创建列表碎片.让我们按照下面的步骤开始: 步骤 描述 1 使用 Andr ...

最新文章

  1. C++的三大特性:封装,继承,多态
  2. jvm性能调优 - 11J线上VM调优案例分享
  3. flex java类转成_Flex 与 java 通讯 【转】
  4. Vim 的补全模式加速器,轻松玩转全部 15 种自动补全模式
  5. Springboot配置不当
  6. BZOJ1734: [Usaco2005 Feb]Aggressive cows 愤怒的牛
  7. 大数据之Kafka入门简介
  8. 未能加载文件或程序集 请移除注册表值 [HKLM/Software/Microsoft/Fusion!EnableLog] 解决方法
  9. 2011-10-10
  10. 多功能通用报修管理平台后勤维修软件
  11. Linux聊天服务器
  12. 智能手机串号IMEI码丢失(无效IMEI)解决恢复办法
  13. 拉卡拉支付最新支付方式预览——刷脸支付上线
  14. python apscheculer 报错 skipped: maximum number of running instances reached (1)
  15. 绘制奥林匹克标志——利用python turtle画奥运五环
  16. 计算机网络复习训练题
  17. 房地产前期投资阶段及启动阶段目标成本形成过程
  18. 告别 PS !3 行代码 5 秒搞定抠图的 AI 神器!
  19. LVM Linear vs Striped Logical Volumes
  20. 创意编程/小学组(4-6年级)-图形化创意

热门文章

  1. 自己开发的ABAP代码版本查看工具
  2. Extension field添加到CDS view上的技术实现
  3. IBASE logical view和physical view
  4. PRDICQR and PRD01QR
  5. SAP CRM Enterprise Search change pointer的存储数据库表
  6. Hybris Enterprise Commerce Platform 服务层的设计与实现
  7. mysql5.1修改登陆密码_mysql 5.1版本修改密码及远程登录mysql数据库的方法
  8. shell中用grep查找并且不输出_shell中grep命令详解
  9. python获取字符串首字母_[Python] Python 获取中文的首字母 和 全部拼音首字母
  10. python google buffer_python调用Google Protocol Buffer