2014-02-12 59 views
0


GetChildView不要求lastItem(ExpandableList與web視圖)

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; 
    } 
} 
+0

您從'getChild()'和'getGroup()' – Emmanuel

+0

返回null爲這兩個方法添加了impl,仍然沒有任何更多的建議 –

+0

嘗試將其從null更改爲需要返回的實際對象。並在isChildSelectable方法中返回true。 –

回答

0


解決我的問題是我已經添加了一個虛擬頁腳我expandableListView。不知道原因,但之後它工作正常。

+0

還補充說,不應該從getChild和getGroup方法返回null,以便用戶獲得完整的解決方案。 :) –

+0

我只是撤銷這些變化......並仍然工作... –

+0

好吧,那麼它的好嗎 –