I implemented a custom listview, with 4 different custom rows. when i display all rows aut one screen every things work. But when I e.g. switch the screen into horizontal format, then the listview have to scroll. When I scroll down and the first item on the top disappears, the app crashes!
Here is the code in the getView method:
    View row = null;
    if(convertView==null){
        LayoutInflater inflater = LayoutInflater.from(context);
        switch (rowFinder[position]){
        case 1: 
                row = inflater.inflate(R.layout.header_sidebar_row, parent, false);
                break;
        case 2: 
                row = inflater.inflate(R.layout.current_club, parent, false);
                break;
        case 3: 
                row = inflater.inflate(R.layout.custom_sidebar_row, parent, false);
                break;
        case 4:
                row = inflater.inflate(R.layout.section_sidebar_header, parent, false);
                break;
        }
    }
    else{
        row = convertView;
    }
    TextView sidebarTitle;
    ImageView iconImage = null;
    switch (rowFinder[position]){
    case 1: 
        sidebarTitle =(TextView) row.findViewById(R.id.user_name);
        iconImage = (ImageView) row.findViewById(R.id.user_image);  
        break;
    case 2:
        sidebarTitle =(TextView) row.findViewById(R.id.club_name);
        iconImage = (ImageView) row.findViewById(R.id.club_image);
        break;
    case 3:
        sidebarTitle =(TextView) row.findViewById(R.id.menu_item);
        iconImage = (ImageView) row.findViewById(R.id.icon_image);  
        break;
    case 4:
        sidebarTitle =(TextView) row.findViewById(R.id.section_item);
        iconImage = null;
        break;
    default:
        sidebarTitle = (TextView) row.findViewById(R.id.menu_item);
        iconImage = null;
        break;
    }
    sidebarTitle.setText(titlesSideMenu[position]);
    if(iconImage != null){
        iconImage.setImageResource(images[position]);
    }
    return row;
}
(Not all of the custom rows have a image)
This is the crash report:
10-05 20:02:08.710: E/InputEventReceiver(2126): Exception dispatching input event.
10-05 20:02:08.730: D/AndroidRuntime(2126): Shutting down VM
10-05 20:02:08.743: W/dalvikvm(2126): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
10-05 20:02:08.800: E/AndroidRuntime(2126): FATAL EXCEPTION: main
10-05 20:02:08.800: E/AndroidRuntime(2126): java.lang.NullPointerException
10-05 20:02:08.800: E/AndroidRuntime(2126):     at com.example.rivler.SidebarListAdapter.getView(SidebarListAdapter.java:125)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.widget.AbsListView.obtainView(AbsListView.java:2143)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.widget.ListView.makeAndAddView(ListView.java:1831)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.widget.ListView.fillDown(ListView.java:674)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.widget.ListView.fillGap(ListView.java:638)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.widget.AbsListView.trackMotionScroll(AbsListView.java:4930)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.widget.AbsListView.scrollIfNeeded(AbsListView.java:3087)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.widget.AbsListView.onTouchEvent(AbsListView.java:3361)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.View.dispatchTouchEvent(View.java:7246)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2168)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1903)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2174)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1917)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1953)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1405)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.app.Activity.dispatchTouchEvent(Activity.java:2410)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1901)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.View.dispatchPointerEvent(View.java:7426)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3220)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3165)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4292)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4271)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4363)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:179)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:171)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:4342)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:4382)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:749)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.Choreographer.doCallbacks(Choreographer.java:562)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.Choreographer.doFrame(Choreographer.java:530)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:735)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.os.Handler.handleCallback(Handler.java:725)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.os.Handler.dispatchMessage(Handler.java:92)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.os.Looper.loop(Looper.java:137)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at android.app.ActivityThread.main(ActivityThread.java:5041)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at java.lang.reflect.Method.invokeNative(Native Method)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at java.lang.reflect.Method.invoke(Method.java:511)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
10-05 20:02:08.800: E/AndroidRuntime(2126):     at dalvik.system.NativeStart.main(Native Method)
For help I would be very grateful!
 
     
     
     
    