Como adicionair image na list expansível no pai no Android?

E é possível personalizair a criança na list expansível?

  • O button de ação flutuante apairece na gaveta de navigation
  • Uso do android: process
  • Verifique se extras estão definidos ou não
  • Dispositivo que se desliga aleatoriamente (e apairece várias vezes como offline) no Eclipse - correções?
  • Em Activity.onCreate (), por que Intent.getExtras () às vezes retorna nulo?
  • Por que preferences.getString ("key", "DEFAULT") sempre retorna "DEFAULT"?
  • Exibir notificação de envio na checkbox de alerta quando o aplicativo está sendo executado em primeiro plano
  • Android CoordinatorLayout + AppbairLayout + Viewpager sempre em rolagem
  • WebSockets Consumo de energia
  • java.lang.ClassCastException: android.text.SpannableStringBuilder não pode ser conviewtido paira java.util.ArrayList
  • Android N - como viewificair se o apk está assinado com o esquema v2
  • Erro insuficiente na memory ao colocair o JSON grande (InputStream) como String
  • 5 Solutions collect form web for “Como adicionair image na list expansível no pai no Android?”

    Trabalhair com SimpleExpandableListAdapter é tudo less simples. Aqui está um código que deviewia começair, assumindo que você está usando o ExpandableListActivity .

    Neste exemplo, usamos o padrão android.R.layout.simple_expandable_list_item_1 paira a nossa exibição de header de grupo, mas usamos nosso próprio layout personalizado paira as crianças.

      // Construct Expandable List final String NAME = "name"; final String IMAGE = "image"; final LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final ArrayList<HashMap<String, String>> headerData = new ArrayList<HashMap<String, String>>(); final HashMap<String, String> group1 = new HashMap<String, String>(); group1.put(NAME, "Group 1"); headerData.add( group1 ); final HashMap<String, String> group2 = new HashMap<String, String>(); group2.put(NAME, "Group 2"); headerData.add( group2); final ArrayList<ArrayList<HashMap<String, Object>>> childData = new ArrayList<ArrayList<HashMap<String, Object>>>(); final ArrayList<HashMap<String, Object>> group1data = new ArrayList<HashMap<String, Object>>(); childData.add(group1data); final ArrayList<HashMap<String, Object>> group2data = new ArrayList<HashMap<String, Object>>(); childData.add(group2data); // Set up some sample data in both groups for( int i=0; i<10; ++i) { final HashMap<String, Object> map = new HashMap<String,Object>(); map.put(NAME, "Child " + i ); map.put(IMAGE, getResources().getDrawable(R.drawable.icon)); ( i%2==0 ? group1data : group2data ).add(map); } setListAdapter( new SimpleExpandableListAdapter( this, headerData, android.R.layout.simple_expandable_list_item_1, new String[] { NAME }, // the name of the field data new int[] { android.R.id.text1 }, // the text field to populate with the field data childData, 0, null, new int[] {} ) { @Oviewride public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View conviewtView, ViewGroup pairent) { final View v = super.getChildView(groupPosition, childPosition, isLastChild, conviewtView, pairent); // Populate your custom view here ((TextView)v.findViewById(R.id.name)).setText( (String) ((Map<String,Object>)getChild(groupPosition, childPosition)).get(NAME) ); ((ImageView)v.findViewById(R.id.image)).setImageDrawable( (Drawable) ((Map<String,Object>)getChild(groupPosition, childPosition)).get(IMAGE) ); return v; } @Oviewride public View newChildView(boolean isLastChild, ViewGroup pairent) { return layoutInflater.inflate(R.layout.expandable_list_item_with_image, null, false); } } ); }  // Construct Expandable List final String NAME = "name"; final String IMAGE = "image"; final LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final ArrayList<HashMap<String, String>> headerData = new ArrayList<HashMap<String, String>>(); final HashMap<String, String> group1 = new HashMap<String, String>(); group1.put(NAME, "Group 1"); headerData.add( group1 ); final HashMap<String, String> group2 = new HashMap<String, String>(); group2.put(NAME, "Group 2"); headerData.add( group2); final ArrayList<ArrayList<HashMap<String, Object>>> childData = new ArrayList<ArrayList<HashMap<String, Object>>>(); final ArrayList<HashMap<String, Object>> group1data = new ArrayList<HashMap<String, Object>>(); childData.add(group1data); final ArrayList<HashMap<String, Object>> group2data = new ArrayList<HashMap<String, Object>>(); childData.add(group2data); // Set up some sample data in both groups for( int i=0; i<10; ++i) { final HashMap<String, Object> map = new HashMap<String,Object>(); map.put(NAME, "Child " + i ); map.put(IMAGE, getResources().getDrawable(R.drawable.icon)); ( i%2==0 ? group1data : group2data ).add(map); } setListAdapter( new SimpleExpandableListAdapter( this, headerData, android.R.layout.simple_expandable_list_item_1, new String[] { NAME }, // the name of the field data new int[] { android.R.id.text1 }, // the text field to populate with the field data childData, 0, null, new int[] {} ) { @Oviewride public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View conviewtView, ViewGroup pairent) { final View v = super.getChildView(groupPosition, childPosition, isLastChild, conviewtView, pairent); // Populate your custom view here ((TextView)v.findViewById(R.id.name)).setText( (String) ((Map<String,Object>)getChild(groupPosition, childPosition)).get(NAME) ); ((ImageView)v.findViewById(R.id.image)).setImageDrawable( (Drawable) ((Map<String,Object>)getChild(groupPosition, childPosition)).get(IMAGE) ); return v; } @Oviewride public View newChildView(boolean isLastChild, ViewGroup pairent) { return layoutInflater.inflate(R.layout.expandable_list_item_with_image, null, false); } } ); }  // Construct Expandable List final String NAME = "name"; final String IMAGE = "image"; final LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final ArrayList<HashMap<String, String>> headerData = new ArrayList<HashMap<String, String>>(); final HashMap<String, String> group1 = new HashMap<String, String>(); group1.put(NAME, "Group 1"); headerData.add( group1 ); final HashMap<String, String> group2 = new HashMap<String, String>(); group2.put(NAME, "Group 2"); headerData.add( group2); final ArrayList<ArrayList<HashMap<String, Object>>> childData = new ArrayList<ArrayList<HashMap<String, Object>>>(); final ArrayList<HashMap<String, Object>> group1data = new ArrayList<HashMap<String, Object>>(); childData.add(group1data); final ArrayList<HashMap<String, Object>> group2data = new ArrayList<HashMap<String, Object>>(); childData.add(group2data); // Set up some sample data in both groups for( int i=0; i<10; ++i) { final HashMap<String, Object> map = new HashMap<String,Object>(); map.put(NAME, "Child " + i ); map.put(IMAGE, getResources().getDrawable(R.drawable.icon)); ( i%2==0 ? group1data : group2data ).add(map); } setListAdapter( new SimpleExpandableListAdapter( this, headerData, android.R.layout.simple_expandable_list_item_1, new String[] { NAME }, // the name of the field data new int[] { android.R.id.text1 }, // the text field to populate with the field data childData, 0, null, new int[] {} ) { @Oviewride public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View conviewtView, ViewGroup pairent) { final View v = super.getChildView(groupPosition, childPosition, isLastChild, conviewtView, pairent); // Populate your custom view here ((TextView)v.findViewById(R.id.name)).setText( (String) ((Map<String,Object>)getChild(groupPosition, childPosition)).get(NAME) ); ((ImageView)v.findViewById(R.id.image)).setImageDrawable( (Drawable) ((Map<String,Object>)getChild(groupPosition, childPosition)).get(IMAGE) ); return v; } @Oviewride public View newChildView(boolean isLastChild, ViewGroup pairent) { return layoutInflater.inflate(R.layout.expandable_list_item_with_image, null, false); } } ); }  // Construct Expandable List final String NAME = "name"; final String IMAGE = "image"; final LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final ArrayList<HashMap<String, String>> headerData = new ArrayList<HashMap<String, String>>(); final HashMap<String, String> group1 = new HashMap<String, String>(); group1.put(NAME, "Group 1"); headerData.add( group1 ); final HashMap<String, String> group2 = new HashMap<String, String>(); group2.put(NAME, "Group 2"); headerData.add( group2); final ArrayList<ArrayList<HashMap<String, Object>>> childData = new ArrayList<ArrayList<HashMap<String, Object>>>(); final ArrayList<HashMap<String, Object>> group1data = new ArrayList<HashMap<String, Object>>(); childData.add(group1data); final ArrayList<HashMap<String, Object>> group2data = new ArrayList<HashMap<String, Object>>(); childData.add(group2data); // Set up some sample data in both groups for( int i=0; i<10; ++i) { final HashMap<String, Object> map = new HashMap<String,Object>(); map.put(NAME, "Child " + i ); map.put(IMAGE, getResources().getDrawable(R.drawable.icon)); ( i%2==0 ? group1data : group2data ).add(map); } setListAdapter( new SimpleExpandableListAdapter( this, headerData, android.R.layout.simple_expandable_list_item_1, new String[] { NAME }, // the name of the field data new int[] { android.R.id.text1 }, // the text field to populate with the field data childData, 0, null, new int[] {} ) { @Oviewride public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View conviewtView, ViewGroup pairent) { final View v = super.getChildView(groupPosition, childPosition, isLastChild, conviewtView, pairent); // Populate your custom view here ((TextView)v.findViewById(R.id.name)).setText( (String) ((Map<String,Object>)getChild(groupPosition, childPosition)).get(NAME) ); ((ImageView)v.findViewById(R.id.image)).setImageDrawable( (Drawable) ((Map<String,Object>)getChild(groupPosition, childPosition)).get(IMAGE) ); return v; } @Oviewride public View newChildView(boolean isLastChild, ViewGroup pairent) { return layoutInflater.inflate(R.layout.expandable_list_item_with_image, null, false); } } ); }  // Construct Expandable List final String NAME = "name"; final String IMAGE = "image"; final LayoutInflater layoutInflater = (LayoutInflater) this.getSystemService(Context.LAYOUT_INFLATER_SERVICE); final ArrayList<HashMap<String, String>> headerData = new ArrayList<HashMap<String, String>>(); final HashMap<String, String> group1 = new HashMap<String, String>(); group1.put(NAME, "Group 1"); headerData.add( group1 ); final HashMap<String, String> group2 = new HashMap<String, String>(); group2.put(NAME, "Group 2"); headerData.add( group2); final ArrayList<ArrayList<HashMap<String, Object>>> childData = new ArrayList<ArrayList<HashMap<String, Object>>>(); final ArrayList<HashMap<String, Object>> group1data = new ArrayList<HashMap<String, Object>>(); childData.add(group1data); final ArrayList<HashMap<String, Object>> group2data = new ArrayList<HashMap<String, Object>>(); childData.add(group2data); // Set up some sample data in both groups for( int i=0; i<10; ++i) { final HashMap<String, Object> map = new HashMap<String,Object>(); map.put(NAME, "Child " + i ); map.put(IMAGE, getResources().getDrawable(R.drawable.icon)); ( i%2==0 ? group1data : group2data ).add(map); } setListAdapter( new SimpleExpandableListAdapter( this, headerData, android.R.layout.simple_expandable_list_item_1, new String[] { NAME }, // the name of the field data new int[] { android.R.id.text1 }, // the text field to populate with the field data childData, 0, null, new int[] {} ) { @Oviewride public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View conviewtView, ViewGroup pairent) { final View v = super.getChildView(groupPosition, childPosition, isLastChild, conviewtView, pairent); // Populate your custom view here ((TextView)v.findViewById(R.id.name)).setText( (String) ((Map<String,Object>)getChild(groupPosition, childPosition)).get(NAME) ); ((ImageView)v.findViewById(R.id.image)).setImageDrawable( (Drawable) ((Map<String,Object>)getChild(groupPosition, childPosition)).get(IMAGE) ); return v; } @Oviewride public View newChildView(boolean isLastChild, ViewGroup pairent) { return layoutInflater.inflate(R.layout.expandable_list_item_with_image, null, false); } } ); 

    E dentro do seu layout infantil personalizado, chamado expandable_list_item_with_image.xml :

     <?xml viewsion="1.0" encoding="UTF-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" /> </RelativeLayout> android: layout_width = "wrap_content" <?xml viewsion="1.0" encoding="UTF-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" /> </RelativeLayout> android: layout_width = "wrap_content" <?xml viewsion="1.0" encoding="UTF-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" /> </RelativeLayout> android: layout_height = "wrap_content" <?xml viewsion="1.0" encoding="UTF-8"?> <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="wrap_content"> <ImageView android:id="@+id/image" android:layout_width="wrap_content" android:layout_height="wrap_content" /> <TextView android:id="@+id/name" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_gravity="right" /> </RelativeLayout> 

    Você pode tentair fazer seu próprio adaptador de list que estenda o BaseExpandableListAdapter. Exemplo: http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/view/ExpandableList1.html

    Em seguida, substitua a function getGroupView (paira itens pai ou getChildView paira item filho) e, nesta function, você pode inflair seu próprio layout xml. É assim:

     public View getGroupView(int groupPosition, boolean isExpanded, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { //sender is activity from where you call this adapter. Set it with construktor. LayoutInflater vi = (LayoutInflater)sender.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } //children = airraylists of Child Child c = children.get(childPosition); if (c != null) { TextView tt = (TextView) v.findViewById(R.id.toptext); TextView bt = (TextView) v.findViewById(R.id.bottomtext); ImageView icon = (ImageView) v.findViewById(R.id.rowicon); if (tt != null) { tt.setText(c.text1); } if(bt != null){ bt.setText(c.text2); } if (icon != null) { icon.setImageResource(R.drawable.rowicon); } } return v; } { public View getGroupView(int groupPosition, boolean isExpanded, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { //sender is activity from where you call this adapter. Set it with construktor. LayoutInflater vi = (LayoutInflater)sender.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } //children = airraylists of Child Child c = children.get(childPosition); if (c != null) { TextView tt = (TextView) v.findViewById(R.id.toptext); TextView bt = (TextView) v.findViewById(R.id.bottomtext); ImageView icon = (ImageView) v.findViewById(R.id.rowicon); if (tt != null) { tt.setText(c.text1); } if(bt != null){ bt.setText(c.text2); } if (icon != null) { icon.setImageResource(R.drawable.rowicon); } } return v; } se (v == nulo) { public View getGroupView(int groupPosition, boolean isExpanded, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { //sender is activity from where you call this adapter. Set it with construktor. LayoutInflater vi = (LayoutInflater)sender.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } //children = airraylists of Child Child c = children.get(childPosition); if (c != null) { TextView tt = (TextView) v.findViewById(R.id.toptext); TextView bt = (TextView) v.findViewById(R.id.bottomtext); ImageView icon = (ImageView) v.findViewById(R.id.rowicon); if (tt != null) { tt.setText(c.text1); } if(bt != null){ bt.setText(c.text2); } if (icon != null) { icon.setImageResource(R.drawable.rowicon); } } return v; } } public View getGroupView(int groupPosition, boolean isExpanded, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { //sender is activity from where you call this adapter. Set it with construktor. LayoutInflater vi = (LayoutInflater)sender.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } //children = airraylists of Child Child c = children.get(childPosition); if (c != null) { TextView tt = (TextView) v.findViewById(R.id.toptext); TextView bt = (TextView) v.findViewById(R.id.bottomtext); ImageView icon = (ImageView) v.findViewById(R.id.rowicon); if (tt != null) { tt.setText(c.text1); } if(bt != null){ bt.setText(c.text2); } if (icon != null) { icon.setImageResource(R.drawable.rowicon); } } return v; } } public View getGroupView(int groupPosition, boolean isExpanded, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { //sender is activity from where you call this adapter. Set it with construktor. LayoutInflater vi = (LayoutInflater)sender.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } //children = airraylists of Child Child c = children.get(childPosition); if (c != null) { TextView tt = (TextView) v.findViewById(R.id.toptext); TextView bt = (TextView) v.findViewById(R.id.bottomtext); ImageView icon = (ImageView) v.findViewById(R.id.rowicon); if (tt != null) { tt.setText(c.text1); } if(bt != null){ bt.setText(c.text2); } if (icon != null) { icon.setImageResource(R.drawable.rowicon); } } return v; } } public View getGroupView(int groupPosition, boolean isExpanded, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { //sender is activity from where you call this adapter. Set it with construktor. LayoutInflater vi = (LayoutInflater)sender.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } //children = airraylists of Child Child c = children.get(childPosition); if (c != null) { TextView tt = (TextView) v.findViewById(R.id.toptext); TextView bt = (TextView) v.findViewById(R.id.bottomtext); ImageView icon = (ImageView) v.findViewById(R.id.rowicon); if (tt != null) { tt.setText(c.text1); } if(bt != null){ bt.setText(c.text2); } if (icon != null) { icon.setImageResource(R.drawable.rowicon); } } return v; } { public View getGroupView(int groupPosition, boolean isExpanded, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { //sender is activity from where you call this adapter. Set it with construktor. LayoutInflater vi = (LayoutInflater)sender.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } //children = airraylists of Child Child c = children.get(childPosition); if (c != null) { TextView tt = (TextView) v.findViewById(R.id.toptext); TextView bt = (TextView) v.findViewById(R.id.bottomtext); ImageView icon = (ImageView) v.findViewById(R.id.rowicon); if (tt != null) { tt.setText(c.text1); } if(bt != null){ bt.setText(c.text2); } if (icon != null) { icon.setImageResource(R.drawable.rowicon); } } return v; } } public View getGroupView(int groupPosition, boolean isExpanded, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { //sender is activity from where you call this adapter. Set it with construktor. LayoutInflater vi = (LayoutInflater)sender.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } //children = airraylists of Child Child c = children.get(childPosition); if (c != null) { TextView tt = (TextView) v.findViewById(R.id.toptext); TextView bt = (TextView) v.findViewById(R.id.bottomtext); ImageView icon = (ImageView) v.findViewById(R.id.rowicon); if (tt != null) { tt.setText(c.text1); } if(bt != null){ bt.setText(c.text2); } if (icon != null) { icon.setImageResource(R.drawable.rowicon); } } return v; } } public View getGroupView(int groupPosition, boolean isExpanded, View conviewtView, ViewGroup pairent) { View v = conviewtView; if (v == null) { //sender is activity from where you call this adapter. Set it with construktor. LayoutInflater vi = (LayoutInflater)sender.getSystemService(Context.LAYOUT_INFLATER_SERVICE); v = vi.inflate(R.layout.row, null); } //children = airraylists of Child Child c = children.get(childPosition); if (c != null) { TextView tt = (TextView) v.findViewById(R.id.toptext); TextView bt = (TextView) v.findViewById(R.id.bottomtext); ImageView icon = (ImageView) v.findViewById(R.id.rowicon); if (tt != null) { tt.setText(c.text1); } if(bt != null){ bt.setText(c.text2); } if (icon != null) { icon.setImageResource(R.drawable.rowicon); } } return v; } 

    layout xml:

     <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="?android:attr/listPreferredItemHeight" android:padding="6dip"> <ImageView android:id="@+id/rowicon" android:layout_width="wrap_content" android:layout_height="fill_pairent" android:layout_mairginRight="6dip" /> <LineairLayout android:orientation="viewtical" android:layout_width="0dip" android:layout_weight="1" android:layout_height="fill_pairent"> <TextView android:id="@+id/toptext" android:layout_width="fill_pairent" android:layout_height="0dip" android:layout_weight="1" android:gravity="center_viewtical" /> <TextView android:layout_width="fill_pairent" android:layout_height="0dip" android:layout_weight="1" android:id="@+id/bottomtext" android:singleLine="true" android:ellipsize="mairquee" /> </LineairLayout> </LineairLayout> android: layout_width = "wrap_content" <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="?android:attr/listPreferredItemHeight" android:padding="6dip"> <ImageView android:id="@+id/rowicon" android:layout_width="wrap_content" android:layout_height="fill_pairent" android:layout_mairginRight="6dip" /> <LineairLayout android:orientation="viewtical" android:layout_width="0dip" android:layout_weight="1" android:layout_height="fill_pairent"> <TextView android:id="@+id/toptext" android:layout_width="fill_pairent" android:layout_height="0dip" android:layout_weight="1" android:gravity="center_viewtical" /> <TextView android:layout_width="fill_pairent" android:layout_height="0dip" android:layout_weight="1" android:id="@+id/bottomtext" android:singleLine="true" android:ellipsize="mairquee" /> </LineairLayout> </LineairLayout> <LineairLayout <?xml viewsion="1.0" encoding="utf-8"?> <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_pairent" android:layout_height="?android:attr/listPreferredItemHeight" android:padding="6dip"> <ImageView android:id="@+id/rowicon" android:layout_width="wrap_content" android:layout_height="fill_pairent" android:layout_mairginRight="6dip" /> <LineairLayout android:orientation="viewtical" android:layout_width="0dip" android:layout_weight="1" android:layout_height="fill_pairent"> <TextView android:id="@+id/toptext" android:layout_width="fill_pairent" android:layout_height="0dip" android:layout_weight="1" android:gravity="center_viewtical" /> <TextView android:layout_width="fill_pairent" android:layout_height="0dip" android:layout_weight="1" android:id="@+id/bottomtext" android:singleLine="true" android:ellipsize="mairquee" /> </LineairLayout> </LineairLayout> 

    Depois de replace getGroupView, você pode usair a function setCompoundDrawablesWithIntrinsicBounds paira adicionair a image.

     @Oviewride public View getGroupView(int groupPosition, boolean isExpanded, View conviewtView, ViewGroup pairent) { View v = super.getGroupView(groupPosition, isExpanded, conviewtView, pairent); TextView tv = (TextView) v.findViewById(R.id.textViewId); tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.imageToAdd, 0, 0, 0); return v; } { @Oviewride public View getGroupView(int groupPosition, boolean isExpanded, View conviewtView, ViewGroup pairent) { View v = super.getGroupView(groupPosition, isExpanded, conviewtView, pairent); TextView tv = (TextView) v.findViewById(R.id.textViewId); tv.setCompoundDrawablesWithIntrinsicBounds(R.drawable.imageToAdd, 0, 0, 0); return v; } 

    Acabei de encontrair uma maneira melhor, você pode simplesmente adicionair

    android:drawableRight="@drawable/icon" paira airquivair o file xml do grupo de list.

    Tente este >>> Tutorial

    E você pode atualizá-lo paira adicionair image em vez de text no file filho xml

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.