Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You can create you own adapter: </p> <pre><code> public class ExpandableAdapter extends BaseExpandableListAdapter { @SuppressWarnings("unused") private Context context; private ArrayList&lt;String&gt; groups; private ArrayList&lt;ArrayList&lt;Expand&gt;&gt; expand; private LayoutInflater inflater; public ExpandableAdapter(Context context, ArrayList&lt;String&gt; groups, ArrayList&lt;ArrayList&lt;Expand&gt;&gt; expand) { this.context = context; this.groups = groups; this.expand = expand; inflater = LayoutInflater.from( context ); } public Object getChild(int groupPosition, int childPosition) { return expand.get( groupPosition ).get( childPosition ); } public long getChildId(int groupPosition, int childPosition) { return (long)( groupPosition*50+childPosition ); } 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.child_row, parent, false); Expand c = (Expand)getChild( groupPosition, childPosition); TextView color = (TextView)v.findViewById( R.id.grp_child_primero); if( color != null ) color.setText( c.getTitulo()); TextView rgb = (TextView)v.findViewById( R.id.grp_child_segundo); if( rgb != null ) rgb.setText( c.getDato()); return v; } public int getChildrenCount(int groupPosition) { return expand.get( groupPosition ).size(); } public Object getGroup(int groupPosition) { return groups.get( groupPosition ); } public int getGroupCount() { return groups.size(); } public long getGroupId(int groupPosition) { return (long)( groupPosition*50 ); } public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { View v = null; if( convertView != null ) v = convertView; else v = inflater.inflate(R.layout.group_row, parent, false); String gt = (String)getGroup( groupPosition ); TextView expandGroup = (TextView)v.findViewById( R.id.grp_child_primero); if( gt != null ) expandGroup.setText( gt ); return v; } public boolean hasStableIds() { return true; } public boolean isChildSelectable(int groupPosition, int childPosition) { return true; } public void onGroupCollapsed (int groupPosition) {} public void onGroupExpanded(int groupPosition) {} } </code></pre> <p>With one xml for rows:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/negro"&gt; &lt;TextView android:id="@+id/grp_child_primero" android:focusable="false" android:textSize="20sp" android:textStyle="bold" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:background="@drawable/negro"/&gt; &lt;TextView android:id="@+id/grp_child_segundo" android:focusable="false" android:textSize="18sp" android:textStyle="normal" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center_vertical" android:background="@drawable/negro"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>And other for groups:</p> <pre><code>&lt;?xml version="1.0" encoding="utf- &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content" android:background="@drawable/negro"&gt; &lt;TextView android:id="@+id/grp_child_primero" android:layout_width="wrap_content" android:paddingLeft="30dp" android:textSize="20sp" android:textColor="@drawable/blanco" android:textStyle="normal" android:layout_height="wrap_content" android:gravity="center_horizontal|center_vertical" android:background="@drawable/negro"/&gt; &lt;/LinearLayout&gt; </code></pre> <p>And after that:</p> <pre><code>ExpandAdapter youadapter = new ExpandAdapter(getApplicationContext(), namesGroups, nameChilds); setListAdapter(youadapter); </code></pre> <p>Where namesGroups and nameChilds are list the data for rows and groups. With the method setListAdapter, you can set the adapter to the ExpandableListActivity ;) And finally Expand class is a simple POJO:</p> <pre><code>public class Expand { public String titulo = null; public String dato = null; public Expand( String titulo, String dato) { this.titulo = titulo; this.dato = dato; } public String getTitulo() { return titulo; } public String getDato() { return dato; } } </code></pre> <p>Looks primarily as getChildView method (in ExpandableAdapter class) is implemented, and some inside if you do not think it is complicated to implement what you want</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload