您好,欢迎光临本网站![请登录][注册会员]  
文件名称: expandableListViewDemo.7z
  所属分类: Android
  开发工具:
  文件大小: 1mb
  下载次数: 0
  上传时间: 2014-10-27
  提 供 者: zhangl*******
 详细说明: package com.expandableListViewDemo; import java.util.ArrayList; import java.util.List; import com.example.expandablelistviewdemo.R; import android.app.Activity; import android.content.Context; import android.os.Bundle; import android.view.Gravity; import android.view.View; import android.view.ViewGroup; import android.widget.AbsListView; import android.widget.BaseExpandableListAdapter; import android.widget.ExpandableListView; import android.widget.TextView; public class TreeLevelActivity extends Activity { List(); TreeNode group0 = new TreeNode(); group0.setText("group0"); TreeNode child0 = new TreeNode(); child0.setText("child0"); List child0list = new ArrayList(); TreeNode child00 = new TreeNode(); child00.setText("child00"); child0list.add(child00); child0.setChildren(child0list); List group0list = new ArrayList(); group0list.add(child0); group0.setChildren(group0list); TreeNode group1 = new TreeNode(); group1.setText("group1"); data.add(group0); data.add(group1); } class MorelevelAdapter extends BaseExpandableListAdapter { private List list; private Context context; public MorelevelAdapter(Context context,List list) { this.context=context; this.list=list; } @Override public Object getChild(int group, int child) { // TODO Auto-generated method stub return list.get(group).getChildren().get(child); } @Override public long getChildId(int groupId, int childId) { // TODO Auto-generated method stub return childId; } @Override public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { // TODO Auto-generated method stub ExpandableListView expandableListView = getchild(); expandableListView.setAdapter(new MorelevelAdapter(TreeLevelActivity.this, list.get(groupPosition).getChildren())); return expandableListView; } public ExpandableListView getchild() { AbsListView.LayoutParams layoutParams = new AbsListView.LayoutParams( ViewGroup.LayoutParams.FILL_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); MyExpandableListView text = new MyExpandableListView( TreeLevelActivity.this); text.setLayoutParams(layoutParams); text.setPadding(36, 0, 0, 0); return text; } /** * * 生成视图 */ 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(TreeLevelActivity.this); 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; } @Override public int getChildrenCount(int group) { // TODO Auto-generated method stub return list.get(group).getChildren().size(); } @Override public Object getGroup(int groupId) { // TODO Auto-generated method stub return list.get(groupId); } @Override public int getGroupCount() { // TODO Auto-generated method stub return list.size(); } @Override public long getGroupId(int groupId) { // TODO Auto-generated method stub return groupId; } @Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { // TODO Auto-generated method stub String title = list.get(groupPosition).getText(); return getGenericView(title); } @Override public boolean hasStableIds() { // TODO Auto-generated method stub return false; } @Override public boolean isChildSelectable(int arg0, int arg1) { // TODO Auto-generated method stub return false; } } } ...展开收缩
(系统自动生成,下载前可以参看下载内容)

下载文件列表

相关说明

  • 本站资源为会员上传分享交流与学习,如有侵犯您的权益,请联系我们删除.
  • 本站是交换下载平台,提供交流渠道,下载内容来自于网络,除下载问题外,其它问题请自行百度
  • 本站已设置防盗链,请勿用迅雷、QQ旋风等多线程下载软件下载资源,下载后用WinRAR最新版进行解压.
  • 如果您发现内容无法下载,请稍后再次尝试;或者到消费记录里找到下载记录反馈给我们.
  • 下载后发现下载的内容跟说明不相乎,请到消费记录里找到下载记录反馈给我们,经确认后退回积分.
  • 如下载前有疑问,可以通过点击"提供者"的名字,查看对方的联系方式,联系对方咨询.
 相关搜索: ListView
 输入关键字,在本站1000多万海量源码库中尽情搜索: