HorizontalListView results in NullPointerException
<p><strong>Problem Solved, had nothing to do with HorizontalListView</strong></p>

<p>I am working on a university project, programming an android app. For this is needed a HorizontalListView. I have used this source: <a href="http://www.dev-smart.com/archives/34" rel="nofollow">http://www.dev-smart.com/archives/34</a></p>

<p>This List provides me with everythingx I need (plus it looks nice), so I don't want to change if it's possible.</p>

<p>The method below in HorizontalListView is giving me grief. For the first few items it runs throught smoothly and then it crashes at the first Line and just gives a NullPointerException. (I have a suspicion that the point were it crashes has something to do with the width of the elements in the list that are displayed, but I am not sure... and it by no means would cover the entire screen)</p>

<p>I am using a custom adapter to populate the list, this seems to be the problem. I tried using a normal ArrayAdapter with just Strings and that works fine. I need the custom adapter because I have to display a TextView and a Button for each element in the list.</p>

<p>HorizontalListView.java</p>

<pre><code>    private void fillListRight(int rightEdge, final int dx) {
    while(rightEdge + dx &lt; getWidth() &amp;&amp; mRightViewIndex &lt; mAdapter.getCount()) {

        View child = mAdapter.getView(mRightViewIndex, mRemovedViewQueue.poll(), this);
        addAndMeasureChild(child, -1);
        rightEdge += child.getMeasuredWidth();

        if(mRightViewIndex == mAdapter.getCount()-1) {
            mMaxX = mCurrentX + rightEdge - getWidth();
        }

        if (mMaxX &lt; 0) {
            mMaxX = 0;
        }
        mRightViewIndex++;
    }

}
</code></pre>

<p>test.xml</p>

<pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" &gt;
&lt;ch.ethz.webofenergy.client.ui.element.HorizontalListView
android:id="@+id/horizontalListView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#000000"
android:gravity="center_horizontal" /&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>listitem.xml</p>

<pre><code>    &lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" &gt; 
&lt;TextView
android:id="@+id/listElement"
android:layout_width="200dip"
android:layout_height="wrap_content"
android:textSize="30dip"
android:textColor="#FFFFFF" /&gt;
&lt;Button
android:id="@+id/testButton"
android:layout_width="fill_parent"
android:layout_height="wrap_content" /&gt;
&lt;/LinearLayout&gt;
</code></pre>

<p>Some pointers as to how I could try to figure out the problem would be appreciated. I know it's not a very clear question :/.</p>
