我是第一次使用可擴展列表視圖的Android開發人員。我正在創建一個應用程序,在這裏我從webservice獲取d可擴展列表視圖的所有內容。我從wevservice中獲取所有內容,但是當可擴展列表視圖中沒有父項的子項時,可擴展列表視圖的自定義適配器merhod getchildcount()返回null並給出空指針異常如何僅顯示列表中的父項沒有孩子,兩者都可用時?沒有孩子的可擴展列表視圖
謝謝
public View getChildView(int p_id, int c_id, boolean bln1, View view,ViewGroup viewgroup) {
// TODO Auto-generated method stub
if (view == null) {
view = inflater.inflate(com.example.eventlive.R.layout.homescreen_list_item_child, viewgroup,false);
}
TextView textView = (TextView) view.findViewById(R.id.list_item_text_child);
//"i" is the position of the parent/group in the list and
//"i1" is the position of the child
textView.setText(mParent.get(p_id).getArrayChildren().get(c_id));
view.setBackgroundResource(R.drawable.child_bg);
//return the entire view
return view;
}
//counts the number of children items so the list knows how many times calls getChildView() method
@Override
public int getChildrenCount(int p_id) {
// TODO Auto-generated method stub
return mParent.get(p_id).getArrayChildren().size();
}
發佈您的代碼.. – Pragnani 2013-04-22 17:31:34