Unable to start activity:UnsupportedOperationException: addView(View, LayoutParams) is not supported

JPHochbaumJPHochbaum USMember ✭✭✭

I am trying to use an arrayAdapter to populate a listview in my spinner. I've used the exact same setup for my other Listviews so I am not sure what this error is telling me to fix. I am not adding any children in my xml and I am the third parameter to my inflate method, as similar errors suggested to fix when I visited STackOverflow.

 public override View GetView(int position, View convertView, ViewGroup parent)
        {
            View row = convertView;

            if (row == null)
            {
                row = LayoutInflater.From(vContext).Inflate(Resource.Layout.spinnerRow, parent, false);
            }

            TextView txtCategory = row.FindViewById<TextView>(Resource.Id.favoriteItem);
            txtCategory.Text = vColumns[position].sDataColumn;

            return row;
        }

 <android.support.v7.widget.Toolbar
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:minHeight="?attr/actionBarSize"
        android:background="?attr/colorPrimary"
        android:id="@+id/toolbar">
      <TextView
            android:id="@+id/favorite"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Choose a Column"
            android:gravity="left"
            android:layout_gravity="left" />
      <Spinner
          android:id="@+id/spinner"
          android:layout_width="150px"
          android:layout_height="wrap_content">
        <ListView
       android:layout_width="match_parent"
       android:layout_height="wrap_content"
       android:id="@+id/spinnerListView" />
        </Spinner>



    </android.support.v7.widget.Toolbar>

Answers

  • JPHochbaumJPHochbaum USMember ✭✭✭

    If I remove the child ListView from my Spinner I won't get the error.

Sign In or Register to comment.