title: Android ListView crashes while scrolling
body: <p>i see a weird bug here.. i have a list view which is populated from the server in an async... it populates first and then displays the list view... but when i scroll down it crashes... from the logs i see it is not related to population of list view and all.. ... can you please help me?</p>
  
  <pre><code>04-12 12:39:54.676: E/AndroidRuntime(1984): FATAL EXCEPTION: main
  04-12 12:39:54.676: E/AndroidRuntime(1984): java.lang.NullPointerException
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.widget.AbsListView.obtainView(AbsListView.java:1304)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.widget.ListView.makeAndAddView(ListView.java:1727)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.widget.ListView.fillUp(ListView.java:682)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.widget.ListView.correctTooHigh(ListView.java:1349)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.widget.ListView.fillGap(ListView.java:624)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.widget.AbsListView.trackMotionScroll(AbsListView.java:2944)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.widget.AbsListView.onTouchEvent(AbsListView.java:2065)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.widget.ListView.onTouchEvent(ListView.java:3315)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.view.View.dispatchTouchEvent(View.java:3766)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:897)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:936)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1671)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1107)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.app.Activity.dispatchTouchEvent(Activity.java:2086)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1655)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.view.ViewRoot.handleMessage(ViewRoot.java:1785)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.os.Handler.dispatchMessage(Handler.java:99)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.os.Looper.loop(Looper.java:123)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at android.app.ActivityThread.main(ActivityThread.java:4627)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at java.lang.reflect.Method.invokeNative(Native Method)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at java.lang.reflect.Method.invoke(Method.java:521)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:878)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:636)
  04-12 12:39:54.676: E/AndroidRuntime(1984):     at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>this is the custom adapter class which extends Base Adapter</p>
  
  <pre><code>@Override
  public int getCount() {
  
      return mAppIconMapList.size();
  }
  
  @Override
  public Object getItem(int position) {
  
      return mAppIconMapList.get(position);
  }
  
  public Object getAppName(int position) {
  
      return mAvaiableApps.get(position);
  }
  
  @Override
  public long getItemId(int position) {
  
      return position;
  }
  
  @Override
  public View getView(final int position, View convertView, ViewGroup parent) {
      // sets the view onto list view
      LinearLayout rowLayout = null;
  
      System.out.println("getView " + position + " " + convertView);
  
      if (convertView == null) {
          // inflating the row
          rowLayout = (LinearLayout) mInflater.inflate(
                  R.layout.list_custom_row, parent, false);
  
          mAppIcon = (ImageView) rowLayout.findViewById(R.id.icon);
          mAppName = (TextView) rowLayout.findViewById(R.id.application);
          mAppName.setTextColor(Color.WHITE);
          mAppHint = (TextView) rowLayout.findViewById(R.id.hint);
          mAppHint.setTextColor(Color.WHITE);
          mDownloadButton = (Button) rowLayout.findViewById(R.id.download);
          mDownloadButton.setFocusable(false);
  
      }
      // else
      // convertView.getTag();
  
  
      mIcon = mAppIconMapList.get(position);
      System.out.println("Icon " + mIcon);
      mCurrentApplication = mAvaiableApps.get(position);
      System.out.println("Current App " + mCurrentApplication);
      mAppIcon.setImageBitmap(mIcon.get(mCurrentApplication));
      mAppName.setText(mCurrentApplication.replace(".apk", ""));
      mAppHint.setText("Click here to view Description");
  
      return rowLayout;
  }
  </code></pre>
  
  <p>And this is how i am calling</p>
  
  <pre><code>mCustomAdapter = new BWCustomAdapter(mCategory, avaiableApps,
                              appIconMap, BWListApplication.this);
                      setListAdapter(mCustomAdapter);
  </code></pre>
  
  <p>and this is my list view</p>
  
  <pre><code>&lt;LinearLayout
      xmlns:android="http://schemas.android.com/apk/res/android"
      android:layout_width="450dip"
      android:layout_height="300dip"
      android:orientation="vertical" &gt;
  
      &lt;ListView
          android:id="@android:id/list"
          android:layout_width="fill_parent"
          android:layout_height="0dp"
          android:layout_weight="1"
          android:fadingEdge="none"
          android:listSelector="@drawable/list_selector" /&gt;
  &lt;/LinearLayout&gt;
  </code></pre>