jagguy
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="MyNewScreen Label"> </activity>
I tried changing manifest file name back to the orginial, and then If I click on the button I get an error.
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
I tried changing manifest file name back to the orginial, and then If I click on the button I get an error.
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="MyNewScreen Label"> </activity>
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
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
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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?
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?
ASKER
In the 1st example you got working what does this coe do because ti still works fine without it.
public void setOb( AndroidMultipleScreenEasyA ctivity obA){
this.ob=obA;
}
public void setOb( AndroidMultipleScreenEasyA
this.ob=obA;
}
>Also how do I go back?
What that means ?
What that means ?
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi jagguy,
From the example link 1,
MyNewScreen.java
Following code is not at all used . You can remove that code...
public void setOb( AndroidMultipleScreenEasyA ctivity 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.btnClick 2);
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/linearLay out1"
android:layout_width="fill _parent"
android:layout_height="fil l_parent" >
<TextView
android:id="@+id/textView1 "
android:layout_width="wrap _content"
android:layout_height="wra p_content"
android:text="I'm screen 2 (main2.xml)"
android:textAppearance="?a ndroid:att r/textAppe aranceLarg e" />
<Button android:id="@+id/btnClick2 "
android:layout_width="100p x"
android:layout_height="50p x"
android:text="Close" />
</LinearLayout>
From the example link 1,
MyNewScreen.java
Following code is not at all used . You can remove that code...
public void setOb( AndroidMultipleScreenEasyA
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.
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.btnClick
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/linearLay
android:layout_width="fill
android:layout_height="fil
<TextView
android:id="@+id/textView1
android:layout_width="wrap
android:layout_height="wra
android:text="I'm screen 2 (main2.xml)"
android:textAppearance="?a
<Button android:id="@+id/btnClick2
android:layout_width="100p
android:layout_height="50p
android:text="Close" />
</LinearLayout>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
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/