[Java for Android App Development] dginzbourg:
I've been struggling for a couple of weeks to solve this problem. I have two expandable views, one inside another. Whenever i click on the second level expandable view items, it won't inflate its children. All i see when i click is a small scroll bar that appears on the right side on the expandable view item itself. Using a simple layout with a fixed textview results in the same behaviour, meaning that the problem isn't within the ShiftListItem object/s.

Also, getChildView() is never been called.

YearListAdapter:

public class YearListAdapter extends BaseExpandableListAdapter {

private Context _context;
private SparseArray<SparseArray<ArrayList<Salary>>> _shiftYears;

public YearListAdapter(
SparseArray<SparseArray<ArrayList<Salary>>> shiftYears,
Context context) {
super();

_context = context;
_shiftYears = shiftYears;

}

public Object getChild(int arg0, int arg1) {
return (null == _shiftYears.get(_shiftYears.keyAt(arg0))) ? null
: _shiftYears.get(_shiftYears.keyAt(arg0)).get(
_shiftYears.get(_shiftYears.keyAt(arg0)).keyAt(arg1));
}

public long getChildId(int arg0, int arg1) {
return arg1;
}

public View getChildView(int arg0, int arg1, boolean arg2,
View convertView, ViewGroup arg4) {

MonthsListView monthLevelExpandable = new MonthsListView(_context);

MonthListAdapter adapter = new MonthListAdapter(_context,
_shiftYears.get(_shiftYears.keyAt(arg0)));
monthLevelExpandable.setAdapter(adapter);

adapter.forceReload();
monthLevelExpandable.setGroupIndicator(null);

return monthLevelExpandable;

}

public int getChildrenCount(int arg0) {
if (null == _shiftYears.get(_shiftYears.keyAt(arg0)))
return 0;
return _shiftYears.get(_shiftYears.keyAt(arg0)).size();
}

public Object getGroup(int arg0) {
return (null == _shiftYears) ? null : _shiftYears.get(_shiftYears
.keyAt(arg0));
}

public int getGroupCount() {
return _shiftYears.size();
}

public long getGroupId(int arg0) {
return arg0;
}

public View getGroupView(int arg0, boolean isExpanded, View convertView,
ViewGroup arg3) {

if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) _context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.year_list_view_item, null);

}

TextView title = (TextView) convertView.findViewById(R.id.yearTitle);
title.setText("" + _shiftYears.keyAt(arg0));

return convertView;

}

public boolean hasStableIds() {
return true;
}

public boolean isChildSelectable(int arg0, int arg1) {
return true;
}

public void forceReload() {
notifyDataSetChanged();
}

}

MonthListAdapter:

public class MonthListAdapter extends BaseExpandableListAdapter {

private Context _context;
private SparseArray<ArrayList<Salary>> _shiftMonths;

public MonthListAdapter(Context context,
SparseArray<ArrayList<Salary>> shiftMonths) {
super();

_context = context;
_shiftMonths = shiftMonths;

}

public Object getChild(int groupPosition, int childPosition) {
return (null == _shiftMonths) ? null : _shiftMonths.get(
_shiftMonths.keyAt(groupPosition)).get(childPosition);

}

public long getChildId(int groupPosition, int childPosition) {
return childPosition;
}

public View getChildView(int groupPosition, int childPosition,
boolean isLastChild, View convertView, ViewGroup parent) {

ShiftListItem sli;
if (null == convertView) {
sli = (ShiftListItem) View.inflate(_context,
R.layout.shift_list_item, null);
} else {
sli = (ShiftListItem) convertView;
}
sli.setSalary(_shiftMonths.get(_shiftMonths.keyAt(groupPosition)).get(
childPosition));
return sli;
}

public int getChildrenCount(int groupPosition) {
if (null == _shiftMonths
|| null == _shiftMonths.get(_shiftMonths.keyAt(groupPosition)))
return 0;
return _shiftMonths.get(_shiftMonths.keyAt(groupPosition)).size();
}

public Object getGroup(int groupPosition) {
return (null == _shiftMonths) ? null : _shiftMonths.get(_shiftMonths
.keyAt(groupPosition));
}

public int getGroupCount() {
return _shiftMonths.size();
}

public long getGroupId(int groupPosition) {
return groupPosition;
}

public View getGroupView(int groupPosition, boolean isExpanded,
View convertView, ViewGroup parent) {

if (convertView == null) {
LayoutInflater inflater = (LayoutInflater) _context
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.month_list_view_item, null);
}

TextView title = (TextView) convertView.findViewById(R.id.monthTitle);
title.setText("" + _shiftMonths.keyAt(groupPosition));

return convertView;

}

public boolean hasStableIds() {
return true;
}

public boolean isChildSelectable(int groupPosition, int childPosition) {
return true;
}

public void forceReload() {
notifyDataSetChanged();
}

}

ShiftListItem:

public class ShiftListItem extends LinearLayout {

private Salary salary;
private TextView itemTimeAndDate;
private TextView itemCashView;

public ShiftListItem(Context context, AttributeSet attrs) {
super(context, attrs);

salary = new Salary();
}
[MENTION=439709]override[/MENTION]
protected void onFinishInflate() {
super.onFinishInflate();
itemTimeAndDate = (TextView) findViewById(R.id.itemTimeAndDate);
itemCashView = (TextView) findViewById(R.id.itemCashView);
}

public void setSalary(Salary salary) {
this.salary = salary;

Calendar start = salary.getShiftTime().getStart();
Calendar end = salary.getShiftTime().getEnd();

int tHour;
int tMinute;
int tSec;

tSec = salary.getShiftTime().getDifference(
salary.getShiftTime().getStart(),
salary.getShiftTime().getEnd());
tHour = tSec / 3600;
tSec -= tHour * 3600;
tMinute = tSec / 60;
tSec -= tMinute * 60;

itemTimeAndDate.setText("Time: (Start) "
+ returnTwoDigitString(start.get(Calendar.HOUR_OF_DAY)) + ":"
+ returnTwoDigitString(start.get(Calendar.MINUTE)) + " (End)"
+ returnTwoDigitString(end.get(Calendar.HOUR_OF_DAY)) + ":"
+ returnTwoDigitString(end.get(Calendar.MINUTE)) + "\n"
+ (start.get(Calendar.DAY_OF_MONTH)) + "-"
+ (end.get(Calendar.DAY_OF_MONTH)) + "/"
+ (start.get(Calendar.MONTH) + 1) + "-"
+ (end.get(Calendar.MONTH) + 1) + "/"
+ start.get(Calendar.YEAR) + "-" + end.get(Calendar.YEAR));
itemCashView.setText(salary.getCash() + " " + salary.getCurrency()
+ " Total Time Of: " + returnTwoDigitString(tHour) + ":"
+ returnTwoDigitString(tMinute) + ":"
+ returnTwoDigitString(tSec));
}

public Salary getSalary() {
return salary;
}

private String returnTwoDigitString(int time) {
if (time < 10) {
return "0" + time;
}

return "" + time;
}
}

shift_list_item.xml:

<?xml version="1.0" encoding="utf-8"?>
<com...ShiftListItem xmlns:android="....."
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<TextView
android:id="@+id/itemTimeAndDate"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textIsSelectable="false" />

<TextView
android:id="@+id/itemCashView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textIsSelectable="false" />

</com.....ShiftListItem>