oi galera,
estou fazendo uma view no android que usa BaseExpandableListAdapter.
Eu consegui fazer aparecer na tela, porém eu mando uma lista com vários itens e ele só mostra apenas 1 item.
Toda vez o groupPosition e o childPosition só ficam na posição 0 (trazendo apenas o primeiro registro da lista).
Segue meu codigo:
`public class CalendarioAdapter extends BaseExpandableListAdapter
{
private Context context;
private LayoutInflater inflater;
private List listaCalendario;
public CalendarioAdapter(Context ctx, List<Calendario> calendarios)
{
context = ctx;
inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
listaCalendario = calendarios;
}
@Override
public int getGroupCount()
{
return listaCalendario.size();
}
@Override
public int getChildrenCount(int groupPosition)
{
return listaCalendario.get(groupPosition).getItens().size();
}
@Override
public Object getGroup(int groupPosition)
{
return listaCalendario.get(groupPosition);
}
@Override
public CalendarioItem getChild(int groupPosition, int childPosition)
{
return listaCalendario.get(groupPosition).getItens().get(childPosition);
}
@Override
public long getGroupId(int groupPosition)
{
return groupPosition;
}
@Override
public long getChildId(int groupPosition, int childPosition)
{
return groupPosition;
}
@Override
public boolean hasStableIds()
{
return false;
}
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
if (!isExpanded)
{
((ExpandableListView) parent).expandGroup(groupPosition); // Expande todos os grupos do ListView
}
if (convertView == null)
{
LayoutInflater infalInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = infalInflater.inflate(R.layout.row_calendario, parent, false);
}
ViewHolderCalendario holderCalendario = new ViewHolderCalendario();
Calendario calendarioAtual = (Calendario)getGroup(groupPosition);
holderCalendario.data = (TextView)convertView.findViewById(R.id.txtData);
holderCalendario.data.setText(DataUtil.formatDataBR(calendarioAtual.getData()));
return convertView;
}
@Override
public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView,
ViewGroup parent)
{
ViewHolderItens holderItens = new ViewHolderItens();
CalendarioItem itemAtual = getChild(groupPosition, childPosition);
//Calendario calendarioAtual = (Calendario) getGroup(groupPosition);
if (convertView == null)
{
LayoutInflater inflater = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
convertView = inflater.inflate(R.layout.row_calendario_item, parent, false);
}
holderItens.txtDescricao = (TextView)convertView.findViewById(R.id.txtDescricaoItem);
holderItens.txtDescricao.setText(itemAtual.getDescricao());
return convertView;
}
@Override
public boolean isChildSelectable(int groupPosition, int childPosition)
{
return false;
}
public class ViewHolderCalendario
{
public TextView data;
public TextView diaSemana;
public ListView lstItens;
}
public class ViewHolderItens
{
public TextView txtDescricao;
public ImageView imagemEstrela;
}
`