ExpandableListView ruft nicht getChildView auf

Dieses Thema im Forum "Android App Entwicklung" wurde erstellt von Raidri, 08.06.2012.

  1. Raidri, 08.06.2012 #1
    Raidri

    Raidri Threadstarter Android-Hilfe.de Mitglied

    Beiträge:
    71
    Erhaltene Danke:
    1
    Registriert seit:
    27.03.2010
    Hi Leute,

    habe das Problem das bei mir die getChildView Funktion nie aufgerufen wird, der Debugger geht auch nicht in diese Funktion. Nur die getGroupView wird aufgerufen. Unten folgt mein SourceCode, vllt kann mir jemand von euch sagen wo dort das Problem ist?

    Vielen Dank schon einmal

    Code:
    private class BadgeListAdapter implements ExpandableListAdapter {
    
    		private ArrayList<ArrayList<Badge>> childList = new ArrayList<ArrayList<Badge>>();
    		
    		public BadgeListAdapter() throws Exception {
    			badgeList = Common.getInstance().api.getBadges(Badges.this);
    			
    			ArrayList<Badge> myBadges = new ArrayList<FreispielAPI.Badge>();
    			ArrayList<Badge> openBadges = new ArrayList<FreispielAPI.Badge>();
    			for (Badge badge : badgeList) {
    				if(badge.achieved){
    					myBadges.add(badge);
    				}else{
    					openBadges.add(badge);
    				}
    			}
    			
    			childList.add(myBadges);
    			childList.add(openBadges);
    		}
    		
    		List<FreispielAPI.Badge> badgeList = null;
    
    		@Override
    		public boolean areAllItemsEnabled() {
    			// TODO Auto-generated method stub
    			return true;
    		}
    
    		@Override
    		public Object getChild(int groupPosition, int childPosition) {
    			return childList.get(groupPosition).get(childPosition);
    		}
    
    		@Override
    		public long getChildId(int groupPosition, int childPosition) {
    			// TODO Auto-generated method stub
    			return (long)( groupPosition*1024+childPosition );
    		}
    
    		@Override
    		public View getChildView(int groupPosition, int childPosition,
    				boolean isLastChild, View convertView, ViewGroup parent) {
    
    			LayoutInflater inflater = (LayoutInflater) Badges.this
    					.getSystemService(LAYOUT_INFLATER_SERVICE);
    			View v = inflater.inflate(R.layout.badge_list_child_item, null);
    			Badge badge = (Badge)getChild(groupPosition, childPosition);
    			((TextView) v.findViewById(R.id.badge_subtitle)).setText(badge.description);
    			return v;
    		}
    
    		@Override
    		public int getChildrenCount(int groupPosition) {
    			// TODO Auto-generated method stub
    			return childList.get(groupPosition).size();
    		}
    
    		@Override
    		public Object getGroup(int groupPosition) {
    			// TODO Auto-generated method stub
    			return null;
    		}
    
    		@Override
    		public int getGroupCount() {
    			// TODO Auto-generated method stub
    			return 2;
    		}
    
    		@Override
    		public long getGroupId(int groupPosition) {
    			// TODO Auto-generated method stub
    			return (groupPosition*1024);
    		}
    
    		@Override
    		public View getGroupView(int groupPosition, boolean isExpanded,
    				View convertView, ViewGroup parent) {
    
    			LayoutInflater inflater = (LayoutInflater) Badges.this
    					.getSystemService(LAYOUT_INFLATER_SERVICE);
    
    			View v = inflater.inflate(R.layout.badge_list_group_item, null);
    
    			if (groupPosition % 2 == 0) {
    				v.setBackgroundColor(getResources().getColor(
    						R.color.listviewItem_background));
    				
    				Button header = (Button)v.findViewById(R.id.header_icon);
    				header.setText(R.string.my_badges);
    			} else {
    				v.setBackgroundColor(getResources().getColor(
    						R.color.listviewItem_background));
    				Button header = (Button)v.findViewById(R.id.header_icon);
    				header.setText(R.string.open_badges);
    			}
    
    //			((TextView) v.findViewById(R.id.badge_name)).setText(badgeList
    //					.get(groupPosition).name);
    //
    //			((ImageView) v.findViewById(R.id.icon))
    //					.setImageDrawable(badgeList.get(groupPosition).icon);
    
    			return v;
    		}
    
    		@Override
    		public boolean hasStableIds() {
    			// TODO Auto-generated method stub
    			return true;
    		}
    
    		@Override
    		public boolean isChildSelectable(int groupPosition, int childPosition) {
    			// TODO Auto-generated method stub
    			return false;
    		}
    
    		@Override
    		public boolean isEmpty() {
    			// TODO Auto-generated method stub
    			return false;
    		}
    
    		@Override
    		public void onGroupCollapsed(int groupPosition) {
    			// TODO Auto-generated method stub
    
    		}
    
    		@Override
    		public void onGroupExpanded(int groupPosition) {
    			// TODO Auto-generated method stub
    
    		}
    
    		@Override
    		public void registerDataSetObserver(DataSetObserver observer) {
    			// TODO Auto-generated method stub
    
    		}
    
    		@Override
    		public void unregisterDataSetObserver(DataSetObserver observer) {
    			// TODO Auto-generated method stub
    
    		}
    
    		@Override
    		public long getCombinedChildId(long groupId, long childId) {
    			// TODO Auto-generated method stub
    			return 0;
    		}
    
    		@Override
    		public long getCombinedGroupId(long groupId) {
    			// TODO Auto-generated method stub
    			return 0;
    		}
    
    	}
    
    
     

Diese Seite empfehlen