0

我有ExpandableListView几个月。每个月里面都有一天,每一天都有一个事件列表。这是描述应该如何显示每一天的 xml 文件:

<LinearLayout
        xmlns:android="http://schemas.android.com/apk/res/android"
        android:orientation="horizontal"
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:id="@+id/expandlist_item_dias"
        android:gravity="center_vertical">


    <TextView android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:id="@+id/list_item_text_child"
              android:textSize="20sp"
              android:padding="10dp"
              android:layout_marginLeft="5dp"/>

    <ListView
        android:id="@+id/listaEventosDia"
        android:layout_width="wrap_content"
        android:layout_height="match_parent"
        />
</LinearLayout>

问题是只显示每天的第一个事件(不要介意重复的事件):在此处输入图像描述

我怎样才能使ListView身高足够展示每一个事件?编辑:

这是列表适配器ExpandableListView

public class AdaptadorListaMeses extends BaseExpandableListAdapter {

    public ArrayList<Mes> meses;

    public Context context;

    public AdaptadorListaMeses(Context context, ArrayList<Mes> meses) {
        super();
        this.context = context;
        this.meses = meses;
    }

    @Override
    public Object getChild(int arg0, int arg1) {
        return meses.get(arg0).dias.get(arg1);
    }

    @Override
    public long getChildId(int groupPosition, int childPosition) {
        return 100*groupPosition + childPosition;
    }

    @Override
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View view, ViewGroup parent) {
        Dia child = (Dia) getChild(groupPosition, childPosition);
        if (view == null) {
            LayoutInflater infalInflater = (LayoutInflater) context
                    .getSystemService(context.LAYOUT_INFLATER_SERVICE);
            view = infalInflater.inflate(R.layout.expandlist_item_dias, null);
        }

        TextView tv = (TextView) view.findViewById(R.id.list_item_text_child);
        tv.setText(child.nombre);
        tv.setTag(child.nombre);
        ListView lv = (ListView) view.findViewById(R.id.listaEventosDia);

        ArrayAdapter<Evento> adapter = new ArrayAdapter<Evento>(context, android.R.layout.simple_list_item_1, android.R.id.text1, child.eventos);

        lv.setAdapter(adapter); 

        return view;
    }

    @Override
    public int getChildrenCount(int groupPosition) {
        return meses.get(groupPosition).dias.size();
    }

    @Override
    public Object getGroup(int groupPosition) {
        return meses.get(groupPosition);
    }

    @Override
    public int getGroupCount() {
        return meses.size();
    }

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

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded,
            View view, ViewGroup parent) {
        Mes group = (Mes) getGroup(groupPosition);
        if (view == null) {
            LayoutInflater inf = (LayoutInflater) context
                    .getSystemService(context.LAYOUT_INFLATER_SERVICE);
            view = inf.inflate(R.layout.expandlist_grupo_meses, null);
        }
        TextView tv = (TextView) view.findViewById(R.id.list_item_text_view);
        tv.setText(group.nombre);
        return view;
    }

    @Override
    public boolean hasStableIds() {
        return true;
    }

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

}
4

0 回答 0