zxdynamite 2016-05-12 13:45 采纳率: 28.6%
浏览 1153
已采纳

关于请求下数据后,怎么在ExpandableListView上展示

是弄成集合还是数组,适配器里面怎么弄,弄成集合的话。
思路乱的不行啊。

  • 写回答

2条回答 默认 最新

  • gloomyfish 博客专家认证 2016-05-12 15:24
    关注

    public class ExpandableAdapter extends BaseExpandableListAdapter{

         private LinkedList<TeacherSumGroupsModel> groupArray;
         private List<LinkedList<TeacherSumGroupDetailModel>> childArray;
         private Context context;
         private LayoutInflater inflater;
    
    
         public ExpandableAdapter(Context context,LinkedList<TeacherSumGroupsModel> courseGroupList,
                    List<LinkedList<TeacherSumGroupDetailModel>> childArray){
             inflater = ((Activity) context).getLayoutInflater();
    
             this.groupArray = courseGroupList;
             this.childArray = childArray;
         }
    
    
    
        public int getGroupCount() {
            // TODO Auto-generated method stub
            return groupArray.size();
        }
    
        public int getChildrenCount(int groupPosition) {
            // TODO Auto-generated method stub
            return childArray.get(groupPosition).size();
        }
    
        public Object getGroup(int groupPosition) {
            // TODO Auto-generated method stub
            return groupArray.get(groupPosition);
        }
    
        public Object getChild(int groupPosition, int childPosition) {
            // TODO Auto-generated method stub
            return childArray.get(groupPosition).get(childPosition);
        }
    
        public long getGroupId(int groupPosition) {
            // TODO Auto-generated method stub
            return groupPosition;
        }
    
        public long getChildId(int groupPosition, int childPosition) {
            // TODO Auto-generated method stub
            return childPosition;
        }
    
        public boolean hasStableIds() {
            // TODO Auto-generated method stub
            return false;
        }
    
        public View getGroupView(int groupPosition, boolean isExpanded,
                View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
    
            TextView title;
    
            if(convertView == null){
                convertView = inflater.inflate(R.layout.simple_listview_item, parent, false);
            }
            title = (TextView) convertView.findViewById(R.id.simple_listview_textview);
            String t = "     "+groupArray.get(groupPosition).getname();
            title.setText(t);
            return convertView;
        }
    
        public View getChildView(int groupPosition, int childPosition,
                boolean isLastChild, View convertView, ViewGroup parent) {
            // TODO Auto-generated method stub
            TextView title;
    
            if(convertView == null){
                convertView = inflater.inflate(R.layout.simple_listview_item, parent, false);
            }
            title = (TextView) convertView.findViewById(R.id.simple_listview_textview);
    
            String account = childArray.get(groupPosition).get(childPosition).getAccount();
            String name = childArray.get(groupPosition).get(childPosition).getName();
            String t = account +"          "+name;
            Log.e("sumlist", "info is " +t);
            title.setText(t);
            return convertView;
        }
    
        public boolean isChildSelectable(int groupPosition, int childPosition) {
            // TODO Auto-generated method stub
            return true;
        }
    
    }
    
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 mysql , 用自己创建的本地主机和用户名 登录不上
  • ¥15 关于#web项目#的问题,请各位专家解答!
  • ¥15 vmtools环境不正常
  • ¥15 请问如何在Ubuntu系统中安装使用microsoft R open?
  • ¥15 jupyter notebook
  • ¥30 informer时间序列预测
  • ¥20 SSR引物多态性分析
  • ¥15 大漠插件在Win11易语言注册调用和免注册灵异事件,VS上注册调用完全没问题
  • ¥15 Addressable缓存机制做热更新的问题
  • ¥15 微信开发者工具vant组件