LayoutInflater throwing exceptions

grizeldi

I have a custom adapter for a listView. When I try to inflate some View it throws an exception. Here's my getView() code:

public View getView(int position, View convertView, ViewGroup parent){
    View row = mInflater.inflate(R.layout.items_list_element, parent);
    CheckBox cb = (CheckBox)row.findViewById(R.id.gotItCheckBox);
    String checked = String.valueOf(cb.isChecked());
    return row;
}

The line View row = mInflater.inflate(R.layout.items_list_element, parent); throws this:

04-16 10:37:59.135      625-625/com.grizeldi.gShopper E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.UnsupportedOperationException: addView(View, LayoutParams) is not supported in AdapterView
        at android.widget.AdapterView.addView(AdapterView.java:461)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:416)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
        at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
        at com.grizeldi.gShopper.adapter.getView(adapter.java:21)
        at android.widget.AbsListView.obtainView(AbsListView.java:1430)
        at android.widget.ListView.measureHeightOfChildren(ListView.java:1216)
        at android.widget.ListView.onMeasure(ListView.java:1127)
        at android.view.View.measure(View.java:8313)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
        at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1017)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:386)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
        at android.view.View.measure(View.java:8313)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
        at android.view.View.measure(View.java:8313)
        at android.widget.LinearLayout.measureVertical(LinearLayout.java:531)
        at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
        at android.view.View.measure(View.java:8313)
        at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3138)
        at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
        at android.view.View.measure(View.java:8313)
        at android.view.ViewRoot.performTraversals(ViewRoot.java:839)
        at android.view.ViewRoot.handleMessage(ViewRoot.java:1859)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:123)
        at android.app.ActivityThread.main(ActivityThread.java:3683)
        at java.lang.reflect.Method.invokeNative(Native Method)
        at java.lang.reflect.Method.invoke(Method.java:507)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
        at dalvik.system.NativeStart.main(Native Method)

Anyone knows what's going on?

EDIT: I've made sure that mInflater isn't null.

Blackbelt

Change

View row = mInflater.inflate(R.layout.items_list_element, parent);

with

View row = mInflater.inflate(R.layout.items_list_element, parent, false);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

TOP Ranking

HotTag

Archive