Amira Elsayed Ismail
Amira Elsayed Ismail

Reputation: 9394

Null pointer exception in ExpandableListView

I have the attached exception when I try to make a ExpandableListView

can anyone help!

enter image description here

this is my method

@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;
    }

this is the xml of my list

<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>

Upvotes: 1

Views: 1324

Answers (3)

Tejas
Tejas

Reputation: 1

Just add this to your ExapndableListview android:divider="@null"

Upvotes: -1

Amira Elsayed Ismail
Amira Elsayed Ismail

Reputation: 9394

I have solved this problem by set divider to my child divider instead of null, I don't know why, but thanks all any way

Upvotes: 2

Ogen
Ogen

Reputation: 6709

Try removing this line:

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

And put this line above the if statement:

mInflater = LayoutInflater.from(context);

Where mInflater is declared as a class variable like so LayoutInflater mInflater;

See if this works.

Upvotes: 0

Related Questions