在expandablelistview中设置页脚

时间:2016-08-02 10:21:28

标签: android expandablelistview

我创建了可扩展的listview.That列表视图包含父和子。我想在子布局中添加页脚。页脚在!st parent中正确设置。如果展开第二个父页脚页位置改变了。如何为所有父母设置页脚底部。

public class ExpandListAdapter extends BaseExpandableListAdapter {

    public static ArrayList<Child> ch_list= new ArrayList<Child>();

    private Context context;
    private ArrayList<Group> groups;
    Button button;
    CheckinAdapter adapter;
    String status;
    private ArrayList<Child> movielist = new ArrayList<Child>();
    public  ViewHolder viewHolder;

    public ExpandListAdapter(Context context, ArrayList<Group> groups) {
        this.context = context;
        this.groups = groups;
    }

    @Override
    public Object getChild(int groupPosition, int childPosition) {
        ArrayList<Child> chList = groups.get(groupPosition).getItems();
        return chList.get(childPosition);
    }

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



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



        final Child child = (Child) getChild(groupPosition, childPosition);

        if (convertView == null) {



            LayoutInflater infalInflater = (LayoutInflater) context
                    .getSystemService(context.LAYOUT_INFLATER_SERVICE);


//            if(childPosition ==0)
//            {
//                convertView = infalInflater.inflate(R.layout.footer_view, null);
//            }
//
//            //Here is the ListView of the ChildView
//            if(childPosition>0 && childPosition<getChildrenCount(groupPosition)-1)
//            {


                convertView = infalInflater.inflate(R.layout.child_item, null);


                TextView  amount = (TextView) convertView.findViewById(R.id.amount);
                TextView food_item = (TextView) convertView.findViewById(R.id.food_item);

                TextView item_count = (TextView) convertView.findViewById(R.id.count);

                String fooditem=child.getfood_name();
                String getamount=child.getfood_total();
                String getitem_count=child.getfood_count();
                String foodiem="foodiem--"+fooditem+"amount--"+getamount+"count--"+getitem_count;

                Log.d("fooditem--",foodiem);

                if (child.getfood_name() != null) {
                    if (!child.getfood_name().equals("null")) {
                        food_item.setText(fooditem);
                    }
                }
                if (child.getfood_total() != null) {
                    if (!child.getfood_total().equals("null")) {
                        amount.setText(getamount);
                    }
                }
                if (child.getfood_count() != null) {
                    if (!child.getfood_count().equals("null")) {
                        item_count.setText(getitem_count);
                    }}

            if(childPosition == getChildrenCount(groupPosition)-1)
            {



                LayoutInflater inflator = LayoutInflater.from(parent.getContext());
                convertView = inflator.inflate(R.layout.child_list, null);
                TextView total_itemamount = (TextView) convertView.findViewById(R.id.total_itemamount);
                TextView servicetax = (TextView) convertView.findViewById(R.id.servicetax);
                TextView grand_total = (TextView) convertView.findViewById(R.id.grand_total);


                if (child.getsubtotal() != null) {
                    if (!child.getsubtotal().equals("null")) {
                        total_itemamount.setText(child.getsubtotal());

                    }
                }
                if (child.getservicetax() != null) {
                    if (!child.getservicetax().equals("null")) {
                        servicetax.setText(child.getservicetax());

                    }
                }
                if (child.getgrand_total() != null) {
                    if (!child.getgrand_total().equals("null")) {
                        grand_total.setText(child.getgrand_total());

                    }
                }
            }


        }
      return convertView;
    }


    @Override
    public int getChildrenCount(int groupPosition) {
        ArrayList<Child> chList = groups.get(groupPosition).getItems();
        return chList.size();
    }

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

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

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

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded,
                             View convertView, ViewGroup parent) {
        Group group = (Group) getGroup(groupPosition);
        if (convertView == null) {
            LayoutInflater inf = (LayoutInflater) context
                    .getSystemService(context.LAYOUT_INFLATER_SERVICE);
            convertView = inf.inflate(R.layout.group_item, null);

            TextView order_id = (TextView)convertView.findViewById(R.id.order_id);
            TextView time = (TextView)convertView.findViewById(R.id.time);
            TextView items = (TextView)convertView.findViewById(R.id.items);
            Button delivered = (Button)convertView.findViewById(R.id.delivered);
            Button accept = (Button)convertView.findViewById(R.id.accept);
            Button decline = (Button)convertView.findViewById(R.id.decline);

           // order_id,order_items,order_status,order_time
            if (group.getorder_id() != null) {
                if (!group.getorder_id().equals("null")) {
                    order_id.setText(group.getorder_id());
                }
            }
    ;


        return convertView;
    }

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

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


}

`

0 个答案:

没有答案