title: ClassCastException using Slide ExpandableListAdapter
body: <p>I'm implementing the <a href="https://github.com/tjerkw/Android-SlideExpandableListView" rel="nofollow">Slide ExpandableListAdapter</a> from Tjerk Wolternik, but am getting a ClassCastException when the list I'm using it on is called.  I'm hoping someone can help me figure out why this is happening.</p>
  
  <p>I am using it on a custom array adapter, as seen here:</p>
  
  <pre><code>public class ResultsAdapter extends ArrayAdapter&lt;String&gt; {
  
  private final LayoutInflater layoutInflater;
  
  public ResultsAdapter(Context context, int textViewResourceId) {
         super(context, textViewResourceId);
         layoutInflater = LayoutInflater.from(context);
  }
  
  @Override
  public View getView(int position, View convertView, ViewGroup parent){
  
      if(convertView == null){            
          convertView = layoutInflater.inflate(R.layout.row, null); //must be overall layout  
      }
  
  
      TextView venName = (TextView) convertView.findViewById(R.id.rowName);
      TextView venAddress = (TextView) convertView.findViewById(R.id.rowAdd);
  
      venName.setText(VenueList.getVenueName(position));
      venAddress.setText(VenueList.getVenueAddress(position));
  
      return convertView;
  }
  </code></pre>
  
  <p>}</p>
  
  <p>The ListView that I am working with is an extension of ListFragment, which is right here:</p>
  
  <pre><code>public class ListFragmentClickable extends ListFragment{
  
    private OnItemSelectedListener listener;
  
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { 
        View view = inflater.inflate(R.layout.activity_results, container, false);
        return view;
    }
  
    @Override
    public void onListItemClick(ListView l, View v, int position, long id) {
        updateDetail(position); //see bottom
    } 
  
    public interface OnItemSelectedListener {
        public void onItemSelected(String name);
    }
  
  
    @Override
    public void onAttach(Activity activity) {
        super.onAttach(activity);
        if (activity instanceof OnItemSelectedListener) {
          listener = (OnItemSelectedListener) activity;
        } else {
          throw new ClassCastException(activity.toString()
              + " must implement ListFragmentClickable.OnItemSelectedListener");
        }
    }
  
    public void updateDetail(int position) {
        String name = VenueList.getVenueName(position);
        listener.onItemSelected(name);
    }
  </code></pre>
  
  <p>} </p>
  
  <p>The logcat is pointing to this portion of the library's code (specifically <code>final LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)target.getLayoutParams();</code>):</p>
  
  <pre><code>    private void updateExpandable(View target, int position) {
  
      final LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)target.getLayoutParams();
      if(openItems.get(position)) {
          target.setVisibility(View.VISIBLE);
          params.bottomMargin = 0;
      } else {
          target.setVisibility(View.GONE);
          params.bottomMargin = 0-viewHeights.get(position);
      }
  }
  </code></pre>
  
  <p>And here is my logcat:</p>
  
  <pre><code>07-31 23:42:20.931: E/AndroidRuntime(3557): FATAL EXCEPTION: main
  07-31 23:42:20.931: E/AndroidRuntime(3557): java.lang.ClassCastException: android.widget.RelativeLayout$LayoutParams
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at com.tjerkw.slideexpandable.library.AbstractSlideExpandableListAdapter.updateExpandable(AbstractSlideExpandableListAdapter.java:222)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at com.tjerkw.slideexpandable.library.AbstractSlideExpandableListAdapter.enableFor(AbstractSlideExpandableListAdapter.java:159)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at com.tjerkw.slideexpandable.library.AbstractSlideExpandableListAdapter.enableFor(AbstractSlideExpandableListAdapter.java:142)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at com.tjerkw.slideexpandable.library.AbstractSlideExpandableListAdapter.getView(AbstractSlideExpandableListAdapter.java:64)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.widget.AbsListView.obtainView(AbsListView.java:1449)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.widget.ListView.onMeasure(ListView.java:1103)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.view.View.measure(View.java:8532)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3261)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.view.View.measure(View.java:8532)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3261)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.view.View.measure(View.java:8532)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3261)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.view.View.measure(View.java:8532)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3261)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.view.View.measure(View.java:8532)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.widget.LinearLayout.measureHorizontal(LinearLayout.java:683)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:311)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.view.View.measure(View.java:8532)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3261)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.view.View.measure(View.java:8532)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.widget.LinearLayout.measureVertical(LinearLayout.java:531)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.widget.LinearLayout.onMeasure(LinearLayout.java:309)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.view.View.measure(View.java:8532)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:3261)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.widget.FrameLayout.onMeasure(FrameLayout.java:250)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.view.View.measure(View.java:8532)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.view.ViewRoot.performTraversals(ViewRoot.java:915)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1991)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.os.Handler.dispatchMessage(Handler.java:99)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.os.Looper.loop(Looper.java:150)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at android.app.ActivityThread.main(ActivityThread.java:4358)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at java.lang.reflect.Method.invokeNative(Native Method)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at java.lang.reflect.Method.invoke(Method.java:507)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
  07-31 23:42:20.931: E/AndroidRuntime(3557):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Can anyone explain to me what is happening?  I'm using a linearlayout in the layout, so I'm not sure what the casting issue is.  My layout follows exactly what is in the github link.  Thanks for the help.</p>
  
  <p>EDIT:  Here is row.xml as well:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  </code></pre>
  
  <p></p>
  
  <pre><code>&lt;TextView
      android:id="@+id/rowName"
      android:layout_width="wrap_content"
      android:layout_height="fill_parent"
      android:textStyle="bold"
      android:textSize="16dp"
      android:focusable="false"
      android:paddingLeft="5dp" /&gt;
  
  &lt;TextView
      android:id="@+id/rowAdd"
      android:layout_width="wrap_content"
      android:layout_height="fill_parent"
      android:layout_below="@id/rowName"
      android:focusable="false"
      android:paddingTop="2dp"
      android:paddingLeft="5dp"/&gt;
  
  &lt;TextView
      android:id="@+id/rowFit"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentRight="true"
      android:layout_alignParentTop="true"
      android:paddingTop="5dp"
      android:paddingRight="10dp"
      android:focusable="false"
      android:textStyle="bold"
      android:textSize="18dp" /&gt;
  
  &lt;TextView
      android:id="@+id/rowDist"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentRight="true"
      android:layout_alignParentBottom="true"
      android:paddingBottom="5dp"
      android:paddingRight="10dp"
      android:focusable="false"/&gt; 
  
  &lt;!-- below this is xml for slide expandablelistview --&gt;
  &lt;Button
      android:id="@+id/expandable_toggle_button"
      android:text="More"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignBottom="@+id/text"
      android:layout_alignParentRight="true"
      android:layout_alignTop="@id/text"/&gt;
  
  &lt;LinearLayout
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"
      android:orientation="horizontal"
      android:id="@+id/expandable"
      android:background="#000000"&gt;
  
      &lt;!-- put whatever you want in the expandable view --&gt;
      &lt;TextView
          android:id="@+id/testtext"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:paddingTop="5dp"
          android:text="testtestest"
          android:paddingRight="10dp"
          android:focusable="false"
          android:textStyle="bold"
          android:textSize="18dp" /&gt;
  
  &lt;/LinearLayout&gt;
  
  &lt;!-- slide expandablelistview xml ends here --&gt;
  </code></pre>
  
  <p></p>