2014-01-06 7 views
1

У меня есть прикрепленное исключение, когда я пытаюсь сделать ExpandableListViewИсключительное исключение указателя в ExpandableListView

может кто-нибудь помочь!

enter image description here

это мой метод

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

     View childView; 

     if (convertView == null) { 

      LayoutInflater infalInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 
      childView = infalInflater.inflate(R.layout.side_menu_child_view,null); 
     } else { 
      childView = convertView; 
     } 

     TextView linkName  = (TextView) childView.findViewById(R.id.child_title_text); 
     LinkEntity linkEntity = getChild(groupPosition, childPosition); 
     linkName.setText(linkEntity.getDisplayName(true)); 
     return childView; 
    } 

это XML из моего списка

<EditText 
    android:id="@+id/search_edit_text" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:inputType="text" 
    android:visibility="gone" /> 

<ExpandableListView 
    android:id="@+id/expandable_side_list_view" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:cacheColorHint="@android:color/transparent" 
    android:childDivider="@null" 
    android:childIndicator="@null" 
    android:divider="@drawable/side_menu_separator" 
    android:dividerHeight="0dp" 
    android:groupIndicator="@null" 
    android:listSelector="@android:color/transparent" > 
</ExpandableListView> 

+1

stacktrace никогда не ссылается ни на один из ваших классов и не может отобразить разделитель, вы установили пользовательский разделитель в xml? –

+0

Опубликуйте свой xml-файл – Piyush

+0

Я обновил сообщение с помощью xml, но исключение исходит из getChildView, список уже показан, но когда я нажимаю элемент группы, чтобы показать его дочерние элементы, я получил исключение –

ответ

2

Я решил эту проблему путем набора разделителем для моего ребенка делителя вместо нулевой, я не знаю, почему, но спасибо всем каким-либо образом

+0

он работал для меня тоже, спасибо. –

0

Попробуйте удалить эту строку:

LayoutInflater infalInflater = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); 

И поставить эту строку выше if заявление:

mInflater = LayoutInflater.from(context); 

Где mInflater объявляется как переменная класса, как так LayoutInflater mInflater;

Смотрите, если это работает.

+0

Я пробовал это раньше, и он не работает, на самом деле я изменил его после прочтения этого сообщения http://stackoverflow.com/questions/2730422/cannot-understand-nullpointerexception- с-custom-adapter –

0

Просто добавьте в ваш ExapndableListview андроида: делитель = "@ нуль «

Смежные вопросы