ExpandableList View Crashed in case of zero Items in a group

1: In Case of if any group has has no items then It Crashed

2: In case if there is only one group then it shows only one item after opening that group.

       public class AssignmentCompletedExpandableAdapter extends BaseExpandableListAdapter {

            private List<String> _listDataHeader; 

            private HashMap<String, List<AssignmentScore>> _listDataChild;

            public AssignmentCompletedExpandableAdapter( List<String> _listDataHeader, 
                                                         HashMap<String, List<AssignmentScore>> _listDataChild ){
                 this._listDataHeader = _listDataHeader;
                 this._listDataChild  = _listDataChild;
            }

            @Override
            public Object getChild(int groupPosition, int childPosititon) {

                        return _listDataChild.get(_listDataHeader.get(groupPosition)).get(childPosititon);

            }

            @Override
            public long getChildId(int groupPosition, int childPosition) {
                return childPosition;
            }

            @Override
            public int getChildrenCount(int groupPosition) {
                return this._listDataChild.size();
            }

            @Override
            public Object getGroup(int groupPosition) {
                return this._listDataHeader.get(groupPosition);
            }

            @Override
            public int getGroupCount() {
                return this._listDataHeader.size();
            }

            @Override
            public long getGroupId(int groupPosition) {
                return groupPosition;
            }

            @Override
            public boolean hasStableIds() {
                return false;
            }

            @Override
            public boolean isChildSelectable(int groupPosition, int childPosition) {
                return false;
            }

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

                    if( convertView == null ){
                            convertView = ((LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).
                                                          inflate(R.layout.layout, null); 

                    }



                            Data data = (Data ) getChild(groupPosition, childPosition);
                        TaggedView view = TaggedView.getTaggedView(convertView);

                            view .name_textView.setText(data.getName());
                            view .score_textView.setText(data.getScore());


                    return convertView;

            }

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

                 if( convertView == null ){
                        convertView =  ((LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE)).
                                                        inflate(R.layout.layoutgroup, null); 
                  }

                 TextView lblListHeader = (TextView)convertView.findViewById(R.id.groupname);
                 lblListHeader.setText((String)getGroup(groupPosition));

                 return convertView;

            }

        }

Answers


I think your getChildrenCount should be changed as below to work as expected. Let me know if this works.

    @Override
    public int getChildrenCount(int groupPosition) {
        return this._listDataChild.get(_listDataHeader.get(groupPosition)).size();
    }

Need Your Help

How to Save excel file in vb.net

vb.net excel gridview folder

Previously , I was trying to export gridview value into excel. but with the code given below i am able to export data into excel. but still not able to Save Automatically that excel file into a fixed

Controlling a background image position of the body

asp.net css

I was wondering if it's possible to affect the positioning of the body; I have a 500 x 500 pixel image I have positioned in the center of the page, set not to repeat. I was wondering if it's possi...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.