2014-03-28 2 views
0

내가 item.user_img 밖으로주고있다ExpandableListView 사용자 정의 항목은 볼

@Override 
    public View getChildView(int groupPosition, int childPosition, boolean isLastChild, View convertView, ViewGroup parent) { 
     ViewHolder holder = null; 
     View vi = convertView; 
     final commentSubItem item = getChild(groupPosition, childPosition); 
     System.out.println(item.user_img); 

내 childviews에서 데이터를 얻을 수하려고 할 때 나는 nullpointer 예외를 받고 있어요 지금 큰 문제에 봉착 오케이 nullpointer 예외입니다. commenterData.getString ("user_img은") 값을 제공하기 때문에 getChildView가 널이 왜 지금은 알아낼 수 없습니다

    publishProgress(new commentSubItem(commenterData.getString("user_id"), 
                commenterData.getString("user_fullname"), 
                commenterData.getString("user_username"), 
                commenterData.getString("user_img"), 
                commentData.getString("comment_data"), 
                commentData.getString("comment_bumps"), 
                main.getString("comment_total"), 
                post_id.toString(), 
                commentData.getString("comment_id"), 
                isBumped)); 

@Override 
     protected void onProgressUpdate(commentSubItem... pI) { 
      super.onProgressUpdate(); 
      adapter.addAdapterSubItem(group_id, pI[0]); 


     public void addAdapterSubItem(int itx, commentSubItem item) { 
      comments.get(itx).subComments.add(item); 
     } 

:

class commentItem{ 
    int is_load_more = 0, position, last_time; 
    public String user_id, user_fullname, user_username, user_img, comment_data, comment_bumps, total_replies, post_id, comment_id, isBumped; 
    public List<commentSubItem> subComments = new ArrayList<commentSubItem>(); 

    public commentItem(int ism, int lt){ 
     is_load_more = ism; 
     last_time = lt; 
    } 

    public commentItem(String uid, String ufn, String uun, String uim, String pd, String pb, String tr, String pid, String cid, String isB){ 
     user_id = uid; 
     user_fullname = ufn; 
     user_username = uun; 
     user_img = uim; 
     comment_data = pd; 
     comment_bumps = pb; 
     total_replies = tr; 
     post_id = pid; 
     comment_id = cid; 
     isBumped = isB; 
    } 

} 

    class commentSubItem{ 
     int is_load_more = 0, position, last_time; 
     public String user_id, user_fullname, user_username, user_img, comment_data, comment_bumps, total_replies, post_id, comment_id, isBumped; 

     public commentSubItem(int ism, int lt){ 
      is_load_more = ism; 
      last_time = lt; 
     } 

     public commentSubItem(String uid, String ufn, String uun, String uim, String pd, String pb, String tr, String pid, String cid, String isB){ 
      user_id = uid; 
      user_fullname = ufn; 
      user_username = uun; 
      user_img = uim; 
      comment_data = pd; 
      comment_bumps = pb; 
      total_replies = tr; 
      post_id = pid; 
      comment_id = cid; 
      isBumped = isB; 
     } 
    } 

    public commentSubItem getChild(int groupPosition, int childPosition) { 
     return comments.get(groupPosition).subComments.get(childPosition); 
    } 

난과의 ArrayList를 작성하고 있습니다. 누구든지 나를 도울 수 있습니까?

편집 : 나는 내가 추가 결국 작동하지 않는 comments.get (ITX) .subcomments.add 등 (항목)를 사용하여 몇 가지 이유로 그것을

답변

0

에 groupPosition을 통과으로 GROUP_ID 올바른 값입니다 의견 클래스 내부 subcomment 기능을 추가 한 다음 미세 더 이상 nullpointer 예외

class commentItem{ 
    int is_load_more = 0, position, last_time; 
    public String user_id, user_fullname, user_username, user_img, comment_data, comment_bumps, total_replies, post_id, comment_id, isBumped; 
    public List<commentSubItem> subComments = new ArrayList<commentSubItem>(); 

    public commentItem(int ism, int lt){ 
     is_load_more = ism; 
     last_time = lt; 
    } 

    public commentItem(String uid, String ufn, String uun, String uim, String pd, String pb, String tr, String pid, String cid, String isB){ 
     user_id = uid; 
     user_fullname = ufn; 
     user_username = uun; 
     user_img = uim; 
     comment_data = pd; 
     comment_bumps = pb; 
     total_replies = tr; 
     post_id = pid; 
     comment_id = cid; 
     isBumped = isB; 
    } 

    public void addSubComment(commentSubItem e){ 
     subComments.add(e); 
    } 

    public void addSubComment(int index, commentSubItem e){ 
     subComments.add(index, e); 
    } 

    public void removeSubComment(commentSubItem e){ 
     subComments.remove(e); 
    } 

    public void removeSubComment(int e){ 
     subComments.remove(e); 
    } 

    public commentSubItem getSubComment(int e){ 
     return subComments.get(e); 
    } 
} 

그럼 난 그냥 이런 식으로 함수를 호출 addadaptersubitem 등에서 그들을 일 전화 :

public commentSubItem getChild(int groupPosition, int childPosition) { 
     return comments.get(groupPosition).getSubComment(childPosition); 
    } 
관련 문제