OMG. Chander you need to read and understand the basics of Android ! There is a way to call or navigate from one activity to other is using Intent.
secondly, not sure,why are you using AbsoulteLayout ? Please start reading the Android documentation, to start with below is the link for your reference. http://developer.android.com/resources/tutorials/hello-world.html Warm Regards, *Mukesh Kumar*, Android Consultant/Freelancer, India,Hyderabad. On Mon, Jan 2, 2012 at 12:34 PM, chander <mohan.c...@gmail.com> wrote: > Hi, Happy new year to all...... > > I am writing a code for simple navigation between different pages in > android application. I created a Button and then on Click event i am > setting my ContentView. i have written same code for 2 buttons working > fine. but when i am writing click event for 3rd button and it > navigates to a page named "encrpyt_file.xml". its not working. its > giving Null pointer exception. please check the code. > > btnEncFile = (Button)findViewById(R.id.btnEncFile); > > // at this line btnEncFile value is coming Null, i checked it using > breakpoints so it is giving NullPointerException > > btnEncFile.setOnClickListener(new View.OnClickListener() > { > > public void onClick(View v) > { > setContentView(R.layout.encrypt_file); > } > }); > > why this exception is coming, i have written the this code many times > in my applications but this time i can't understand why its giving > null pointer. > > please suggest me something if i am missing out something? > > 2- "encrypt_file.xml" > > <?xml version="1.0" encoding="utf-8"?> > <AbsoluteLayout xmlns:android="http://schemas.android.com/apk/res/ > android" > android:layout_width="match_parent" > android:layout_height="match_parent" > android:orientation="vertical"> > <Button > android:id="@+id/btnEncFile" > android:layout_width="match_parent" > android:layout_height="50dp" > android:drawableLeft="@drawable/icon" > android:text="Encrypt File"/> > > </AbsoluteLayout> > > > > Thanks > Chandra Mohan > > -- > You received this message because you are subscribed to the Google > Groups "Android Developers" group. > To post to this group, send email to android-developers@googlegroups.com > To unsubscribe from this group, send email to > android-developers+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/android-developers?hl=en -- -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en