没有为lastItem调用GetChildView(带有webView的ExpandableList)

时间:2014-02-12 04:09:12

标签: android expandablelistview expandablelistadapter


最后一项不会被叫{p> getChildView! ,对于其他项目,它工作正常。 (在我的大多数情况下,我将有2个父母,每个父母有一个孩子)。

public class PDPContentAdapter extends BaseExpandableListAdapter {

    private Context context;
    private List<String> groupList;
    private List<List<String>> childList;
    private boolean isTSV;

    public PDPContentAdapter(Context context, List<String> groupList, List<List<String>> childList, boolean isTSV) {
        this.context = context;
        this.groupList = groupList;
        this.childList = childList;
        this.isTSV = isTSV;
    }

    @Override
    public Object getChild(int groupPosition, int childPosition) {
        return ((List<String>)childList.get(groupPosition)).get(childPosition);
    }

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

    @Override
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) {
        String content = ((List<String>) childList.get(groupPosition)).get(childPosition);
        Log.e("PDPContent Adapater", groupPosition +"-------"+childPosition);




            WebView webView = new WebView(context);
            webView.loadData("Hello", "text/html",null);        
            return webView;

    }

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

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

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

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

    @Override
    public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
        TextView view = new TextView(context);
        if(isExpanded)
            view.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.pdp_collapse, 0);
        else
            view.setCompoundDrawablesWithIntrinsicBounds(0, 0, R.drawable.pdp_expand, 0);
        view.setText(groupList.get(groupPosition));
        return view;
    }

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

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

1 个答案:

答案 0 :(得分:0)


解决我的问题是我在expandableListView中添加了一个虚拟页脚。不知道原因,但之后它工作正常。