title: ViewFlipper.setDisplayedChild() is not Working in Android
body: <p>I have my ViewFlipper layout like this,</p>
  
  <pre><code>   &lt;ViewFlipper xmlns:android="http://schemas.android.com/apk/res/android"
      android:id="@+id/flipper"
      android:layout_width="fill_parent"
      android:layout_height="fill_parent"&gt;
       &lt;include android:id="@+id/mainView"  layout="@layout/activity_main" /&gt;
       &lt;include android:id="@+id/readingView"  layout="@layout/get_reading" /&gt;
       &lt;include android:id="@+id/datePickView" layout="@layout/custom_dialog" /&gt;
      &lt;/ViewFlipper&gt;
  </code></pre>
  
  <p>and in the MainActivity,</p>
  
  <pre><code>  public class MainActivity extends Activity {
  
    final Context context = this;
    public ViewFlipper flipper;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);   
      flipper = (ViewFlipper) findViewById(R.id.flipper);
    //Inflate the Views      
      setContentView(R.layout.activity_main);
      Button AddWaterReading=(Button)findViewById(R.id.button1);    //click on + button.
      AddWaterReading.setOnClickListener(new View.OnClickListener() {
  
          @Override
          public void onClick(View v) {
  
              flipper.setDisplayedChild(R.id.readingView);
              TextView txtgetCurrentDate=(TextView)findViewById(R.id.editText1);
              final Calendar c=Calendar.getInstance();
              txtgetCurrentDate.setText((c.get(Calendar.MONTH)+1)+"/"+c.get(Calendar.DATE)+"/"+c.get(Calendar.YEAR));                         
          }
      });
      }
  </code></pre>
  
  <p>when I click on the button "AddWaterReading, the Layout view is not changing to "readingView". I have used the ViewFlipper to change from Main layout to another Layout. But the Application error is shown up ("Unfortunately Application has stopped").</p>
  
  <p>Logcat:</p>
  
  <pre><code>   03-01 07:29:58.122: E/Trace(3924): error opening trace file: No such file or   directory               (2)
     03-01 07:29:59.102: I/Choreographer(3924): Skipped 200 frames!  The application may   be doing too much work on its main thread.
     03-01 07:29:59.232: D/gralloc_goldfish(3924): Emulator without GPU emulation detected.
     03-01 07:30:07.972: D/AndroidRuntime(3924): Shutting down VM
     03-01 07:30:07.972: W/dalvikvm(3924): threadid=1: thread exiting with uncaught exception (group=0x2bd39930)
     03-01 07:30:07.982: E/AndroidRuntime(3924): FATAL EXCEPTION: main
     03-01 07:30:07.982: E/AndroidRuntime(3924): java.lang.NullPointerException
     03-01 07:30:07.982: E/AndroidRuntime(3924):  at com.example.electricityreading.MainActivity$1.onClick(MainActivity.java:35)
     03-01 07:30:07.982: E/AndroidRuntime(3924):  at android.view.View.performClick(View.java:4202)
     03-01 07:30:07.982: E/AndroidRuntime(3924):  at android.view.View$PerformClick.run(View.java:17340)
     03-01 07:30:07.982: E/AndroidRuntime(3924):  at android.os.Handler.handleCallback(Handler.java:725)
     03-01 07:30:07.982: E/AndroidRuntime(3924):  at android.os.Handler.dispatchMessage(Handler.java:92)
     03-01 07:30:07.982: E/AndroidRuntime(3924):  at android.os.Looper.loop(Looper.java:137)
    03-01 07:30:07.982: E/AndroidRuntime(3924):   at android.app.ActivityThread.main(ActivityThread.java:5039)
    03-01 07:30:07.982: E/AndroidRuntime(3924):   at java.lang.reflect.Method.invokeNative(Native Method)
    03-01 07:30:07.982: E/AndroidRuntime(3924):   at java.lang.reflect.Method.invoke(Method.java:511)
    03-01 07:30:07.982: E/AndroidRuntime(3924):   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
    03-01 07:30:07.982: E/AndroidRuntime(3924):   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
    03-01 07:30:07.982: E/AndroidRuntime(3924):   at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>Can anyone please suggest how to switch between Layouts? I am new to Android.</p>
  
  <p>Thanks.</p>