Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing two different layouts for child items in ExpandableListView
    primarykey
    data
    text
    <p>I'm trying to do the <code>ExpandableListView</code> to use two different layouts depending on item type. At this time I made basic functionality except one thing: after selecting a group in the <code>listview</code>, the child item's text is displayed wrong (text of different items is mixed)</p> <p>My <code>adapter</code> source code is following:</p> <pre><code>SimpleExpandableListAdapter adapter = new SimpleExpandableListAdapter( this, groupData, com.oleg.mart.foreign.R.layout.group_row, groupFrom, new int[] { com.oleg.mart.foreign.R.id.Group }, childData, R.layout.simple_list_item_1, childFrom, childTo) { @Override public int getChildTypeCount() { return 2; } /*@Override public int getChildrenCount(int groupPosition) { return childData.get(groupPosition).size(); } */ @Override public int getChildType(int groupPosition, int childPosition) { int result = 0; if (childPosition == getChildrenCount(groupPosition) - 1) result = 1; return result; } @Override public View getChildView ( int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { if (convertView == null) { TextView textView = null; LayoutInflater inflater = (LayoutInflater)getSystemService(getBaseContext().LAYOUT_INFLATER_SERVICE); int itemType = getChildType(groupPosition,childPosition); String myText = childData.get(groupPosition).get(childPosition).get("chapter"); switch (itemType) { case 0: convertView = inflater.inflate(com.oleg.mart.foreign.R.layout.child_row_notlast, null); textView = (TextView)convertView.findViewById(com.oleg.mart.foreign.R.id.NChild); textView.setPadding(30,20,30,20); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); textView.setText(Html.fromHtml(myText)); break; case 1: convertView = inflater.inflate(com.oleg.mart.foreign.R.layout.child_row, null); textView = (TextView)convertView.findViewById(com.oleg.mart.foreign.R.id.Child); textView.setPadding(30,20,30,20); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); textView.setText(Html.fromHtml(myText)); break; } } return convertView; } }; </code></pre> <p>As you can see I'm trying to set a different style on the last child item. What could be wrong?</p> <p><strong>Right <code>getChildView</code> method:</strong></p> <pre><code>TextView textView = null; String myText = null; myText = childData.get(groupPosition).get(childPosition).get("chapter"); if (convertView == null) { LayoutInflater inflater = (LayoutInflater)getSystemService(getBaseContext().LAYOUT_INFLATER_SERVICE); int itemType = getChildType(groupPosition,childPosition); switch (itemType) { case 0: convertView = inflater.inflate(com.oleg.mart.foreign.R.layout.child_row_notlast, null); break; case 1: convertView = inflater.inflate(com.oleg.mart.foreign.R.layout.child_row, null); break; } } textView = (TextView)convertView.findViewById(com.oleg.mart.foreign.R.id.NChild); textView.setPadding(30,20,30,20); textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15); textView.setText(Html.fromHtml(myText)); return convertView; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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