Link to home
Start Free TrialLog in
Avatar of jagguy
jagguyFlag for Australia

asked on

create multi screen app

Hi,

I am having trouble ceating a multi-screen ap in android/eclipse. I just want to clikc a button and another screen appears like

http://start-jandroid.blogspot.com.au/2011/01/android-multiple-screen-example.html

what happens is that the second screen opens on startup, I click the button and the app sems to close without error. The firsy screen never appears.

<activity android:name=".MyNewScreen" android:label="MyNewScreenLabel"> </activity>

I tried changing manifest file name back to the orginial, and then If I click on the button I get an error.
Avatar of jagguy
jagguy
Flag of Australia image

ASKER

I also tried this and got an error at

Description      Resource      Path      Location      Type
The method onClick(View) of type new View.OnClickListener(){} must override a superclass method      MultScreenActivity.java      /multScreen/src/com/ms      line 32      Java Problem




http://www.mkyong.com/android/android-activity-from-one-screen-to-another-screen/
I strictly followed theri instructopions and it works for me
Only Close button is a little bit smallfor the word - writes "Clos"
Otherewise all is OK.

Did you place this correctly after the closing fo the prveious actavity-
after</activity> :
<activity android:name=".MyNewScreen" android:label="MyNewScreenLabel"> </activity>
Avatar of jagguy

ASKER

MY error in in Main file appActivity onClick(View) of type new View.OnClickListener(){} must override a superclass

      public void onClick(View arg0) {

also this has a warning
final Context context = this;

I am using ver 2.2 as this is my phones versions
Avatar of jagguy

ASKER

this gives the error  @Override however the app doesnt work when clicking buttn to go to next screen
I'm not sure I understan what you mean - I just have two activities - exactly pasted the code as they show - one is ANdroidMutipleScreenEasy another is MyNewScreen - eaxctly as they show, and the i repaced contents f main.xml and added my_new_screen.xml to the layout foleder, pasted form their screen ther also, and then add this line to Manifest - afeter that just ran it  - dodn't change anything form their code
Maybe that is the isssue - I'm using 4.0.3
SOLUTION
Avatar of for_yan
for_yan
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of jagguy

ASKER

ok forget 4.03 as this is no good to me. My phone os 2.2 and it is a new phone .

Create this file in 2.2 . I did get this to work but I had to remove the @Overrides

http://www.mkyong.com/android/android-activity-from-one-screen-to-another-screen/

Also how do I go back?
Avatar of jagguy

ASKER

In the 1st example you got working what does this coe do because ti still works fine without it.

  public void setOb( AndroidMultipleScreenEasyActivity obA){
          this.ob=obA;
         }
>Also how do I go back?

What that means ?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi jagguy,

From the example link 1,
MyNewScreen.java
Following code is not at all used . You can remove that code...

 public void setOb( AndroidMultipleScreenEasyActivity obA){
          this.ob=obA;
}

and you  can remove setResult(RESULT_OK);. If you start the second activity MyNewScreen for result from the AndroidMultipleScreenEasy it will be usefull to send the result back to the activity AndroidMultipleScreenEasy .

AndroidMultipleScreenEasy.java
You can remove the use less object  creation....MyNewScreen obB=new MyNewScreen();

Also how do I go back?

Do you want go back to the previoud activity from the App2Activity ?

Then copy past the following code from the "MyNewScreen "  inside the oncreate() of "App2Activity "

  Button b = (Button) findViewById(R.id.btnClick2);
      b.setOnClickListener(new View.OnClickListener() {
         public void onClick(View arg0) {
              finish();
         }
      });

Change the main2.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/linearLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent" >
 
    <TextView
        android:id="@+id/textView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="I&apos;m screen 2 (main2.xml)"
        android:textAppearance="?android:attr/textAppearanceLarge" />
      <Button android:id="@+id/btnClick2"
                    android:layout_width="100px"
                    android:layout_height="50px"
                    android:text="Close" />
</LinearLayout>
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
In 233 looks even better than in 403:
User generated imageUser generated image