@Override public View getChildView( int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { View v = null; if (convertView != null) v = convertView; else v = inflater.inflate(R.layout.favoris_item_view, parent, false); LigneModel ligneModel = (LigneModel) getChild(groupPosition, childPosition); ImageView imgNumLigne = (ImageView) v.findViewById(R.id.imgNumLigne); int imageResource; Drawable image; if (imgNumLigne != null) { imageResource = ctx.getResources() .getIdentifier( LigneModelService.getNumLigneImage( ligneModel.getTypeLigne(), ligneModel.getNumLigne()), "drawable", ctx.getPackageName()); if (imageResource != 0) { image = ctx.getResources().getDrawable(imageResource); imgNumLigne.setImageDrawable(image); imgNumLigne.setPadding(60, 0, 0, 0); } else { imgNumLigne.setImageDrawable(null); } } ImageButton btnFavorite = (ImageButton) v.findViewById(R.id.btnFavorite); btnFavorite.setFocusable(false); imgNumLigne.setFocusable(false); if (ligneModel.isFavoris()) { btnFavorite.setImageDrawable(ctx.getResources().getDrawable(android.R.drawable.star_big_on)); } else { btnFavorite.setImageDrawable(ctx.getResources().getDrawable(android.R.drawable.star_big_off)); } return v; }
@Override public View getGroupView( int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { View v; if (convertView != null) v = convertView; else v = inflater.inflate(R.layout.favoris_group_view, parent, false); String typeLigne = (String) getGroup(groupPosition); int nbFavorisGroup = 0; for (LigneModel ligne : this.lignesChildrenGroups.get(groupPosition)) { if (ligne.isFavoris()) { nbFavorisGroup++; } } ImageView imgTypeLigne = (ImageView) v.findViewById(R.id.imgTypeLigne); TextView lblNbFavoris = (TextView) v.findViewById(R.id.lblNbFavoris); ImageView imgFavoris = (ImageView) v.findViewById(R.id.imgFavoris); int imageResource; Drawable image; if (imgTypeLigne != null) { imageResource = ctx.getResources() .getIdentifier( LigneModelService.getTypeLigneImage(typeLigne), "drawable", ctx.getPackageName()); image = ctx.getResources().getDrawable(imageResource); imgTypeLigne.setImageDrawable(image); imgTypeLigne.setPadding(60, 0, 0, 0); } lblNbFavoris.setText(String.valueOf(nbFavorisGroup)); if (nbFavorisGroup > 0) { imgFavoris.setImageDrawable(ctx.getResources().getDrawable(android.R.drawable.star_big_on)); } else { imgFavoris.setImageDrawable(ctx.getResources().getDrawable(android.R.drawable.star_big_off)); } return v; }