Never mind, the code was perfectly fine I added the android:id
attribute for creating the button id and it works fine for me now.

Thanks,
Susama

On Oct 21, 11:50 am, sush <[EMAIL PROTECTED]> wrote:
> Hello Ludwig,
>
> Basically what I meant was that, I have a class Screen1.java and it
> has a button in it clicking to which should switch to anotherscreen
> which also has one nore button.Clicking on the other button in the
> secondscreenshould end the activity(child activity).This was the
> simplest code that I wanted to implement to work withchanging
> screens, but when I run this application in the ddms logcat I can find
> only creash report and a pop up saying the application has stopped
> unexpectedly in the emulator.
>
> Please let me know if I am doing some thing wrong.
>
> I am pasting below the code snippet for Screen1.java:
>
> public void onCreate(Bundle icicle)
>    {
>       super.onCreate(icicle);
>       setContentView(R.layout.screen1);
>       Button b = (Button) findViewById(R.id.btnClick);
>       b.setOnClickListener(new View.OnClickListener() {
>          public void onClick(View arg0) {
>          Intent i = new Intent(Screen1.this, Screen2.class);
>          startActivity(i);
>          }
>       });
>    }
>
> (In the screen1.xml there is a button component along with a TestView
> to display a text)
>
> Code snippet for Screen2.java;
> public void onCreate(Bundle icicle)
>    {
>       super.onCreate(icicle);
>       setContentView(R.layout.screen2);
>       Button b = (Button) findViewById(R.id.btnClick2);
>       b.setOnClickListener(new View.OnClickListener() {
>          public void onClick(View arg0) {
>          setResult(RESULT_OK);
>          finish();
>          }
>       });
>    }
>
> (In the screen2.xml there is a button component along with a TestView
> to display a text)
>
> And the androidmanifest.xml;
>
> <?xml version="1.0" encoding="utf-8"?>
> <manifest xmlns:android="http://schemas.android.com/apk/res/android";
>       package="ScreenChangeProj.pac"
>       android:versionCode="1"
>       android:versionName="1.0.0">
>     <application android:icon="@drawable/icon" android:label="@string/
> app_name">
>         <activity android:name=".Screen1"
>                   android:label="@string/app_name">
>             <intent-filter>
>                 <action android:name="android.intent.action.MAIN" />
>                 <category
> android:name="android.intent.category.LAUNCHER" />
>             </intent-filter>
>         </activity>
>         <activity android:name=".Screen2" android:label="Screen2">
>       </activity>
>  </application>
> </manifest>
>
> Regards,
> Susama
>
> On Oct 20, 5:57 pm, Ludwig <[EMAIL PROTECTED]> wrote:
>
> > I do not think that you have given enough information for anyone to really
> > help you.
> > Navigating via intents is the primary (only?) way of moving fromscreento
> >screenin Android, so you can safely assume that this works.
> > Looking at the log output in DDMS and the stack-trace in the debugger (plus
> > the information in the exception that is likely being thrown somewhere)
> > might give you an idea what you have done wrong.
>
> > A good start might be just looking at the examples in the samples/ApiDemos
> > directory of the SDK installation and have a look how it is done there.
>
> > Ludwig
>
> > 2008/10/20 sush <[EMAIL PROTECTED]>
>
> > > Hello,
>
> > > I am trying to execute an Android application which will create a new
> > > activity (that will open a new UIscreen) on a button click.
> > > I have stated the new activity as an intent in the main class and
> > > added it in the androidmanifest file as another activity.
> > > But when I execute this application I get an error in the emulator
> > > saying the application has stopped unxpectedly.
>
> > > Please help in this if there are some other way to navigate from one
> > >screento another.
>
> > > Regards,
> > > Susama
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to