android class using viewflipper
<p>I am using four different class for the view now I want to combine the object of the four class in the one class then want to implement the ontouchlistener but it is showing me the error. I am not understanding that error. My code is as follow:</p>

<pre><code>public class AdActivity extends Activity {

    DemoView demoview ;
    DemoView2 finalview;
    DemoView3 dview;
    DemoView4 deview;
    LowerView lview;
    Finalview fview;

    ViewFlipper c,d ;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        demoview = new DemoView(this);
        finalview = new DemoView2(this);
        dview= new DemoView3(this);
        deview = new DemoView4(this);
        lview= new LowerView(this);
        fview=new Finalview(this);
        setContentView(fview);
    }

    public class Finalview extends View {
        public Finalview(Context context) {
            super(context);
            // TODO Auto-generated constructor stub
            c=(ViewFlipper)findViewById(R.id.viewFlipper2);
            c.addView(demoview,0);
            c.addView(finalview, 1);
            c.addView(dview, 2);
            c.addView(deview, 3);
            c.setAutoStart(true);
            c.setFlipInterval(1000);
            c.startFlipping();

            d=(ViewFlipper)findViewById(R.id.viewFlipper3);
            d.addView(lview,0);
        }
    } 
}
</code></pre>

<p>my stack trace is showing the following error.i am not getting this error.</p>

<pre><code>05-07 15:28:56.900: E/AndroidRuntime(515): FATAL EXCEPTION: main
05-07 15:28:56.900: E/AndroidRuntime(515): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.ad/com.example.ad.AdActivity}: java.lang.NullPointerException
05-07 15:28:56.900: E/AndroidRuntime(515):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
05-07 15:28:56.900: E/AndroidRuntime(515):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
05-07 15:28:56.900: E/AndroidRuntime(515):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
05-07 15:28:56.900: E/AndroidRuntime(515):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
05-07 15:28:56.900: E/AndroidRuntime(515):  at android.os.Handler.dispatchMessage(Handler.java:99)
05-07 15:28:56.900: E/AndroidRuntime(515):  at android.os.Looper.loop(Looper.java:123)
05-07 15:28:56.900: E/AndroidRuntime(515):  at android.app.ActivityThread.main(ActivityThread.java:4627)
05-07 15:28:56.900: E/AndroidRuntime(515):  at java.lang.reflect.Method.invokeNative(Native Method)
05-07 15:28:56.900: E/AndroidRuntime(515):  at java.lang.reflect.Method.invoke(Method.java:521)
05-07 15:28:56.900: E/AndroidRuntime(515):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
05-07 15:28:56.900: E/AndroidRuntime(515):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
05-07 15:28:56.900: E/AndroidRuntime(515):  at dalvik.system.NativeStart.main(Native Method)
05-07 15:28:56.900: E/AndroidRuntime(515): Caused by: java.lang.NullPointerException
05-07 15:28:56.900: E/AndroidRuntime(515):  at com.example.ad.AdActivity$Finalview.&lt;init&gt;(AdActivity.java:420)
05-07 15:28:56.900: E/AndroidRuntime(515):  at com.example.ad.AdActivity.onCreate(AdActivity.java:44)
05-07 15:28:56.900: E/AndroidRuntime(515):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
05-07 15:28:56.900: E/AndroidRuntime(515):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
05-07 15:28:56.900: E/AndroidRuntime(515):  ... 11 more
</code></pre>
