Hey everyone! Im trying to add a second activity to my android project, but im not sure how to add the activity files exactly?
Ive added a class here "Name/Scr/PackageName/MyClassHere" but Im not sure if that the correct thing to do or place to put it, because there isnt a XML file either.
Im using this code to open a new screen, http://learnandroid.blogspot.com/2008/01/opening-new-screen-in-android.html And I get 2 error's.
1 at runtimeon this line:
Intent i = new Intent(Coinparison.this, ResultsScreen.class);
it says it cant find my activity.
And the other error here setContentView(R.layout.ResultsScreen);
which says "ResultsScreen" cannot be resolved.
Not sure whats wrong, but any help is great! :)
Most apps contain multiple screens, which means they comprise multiple activities. Typically, one activity in an app is specified as the main activity, which is the first screen to appear when the user launches the app. Each activity can then start another activity in order to perform different actions.
There is a wizard in eclipse now for adding activities, just right click on your project, go to new -> other -> android -> Android Activity
This will create the class, layout and manifest entry.
Add your activity to AndroidManifest.xml
<activity android:name="ResultsScreen"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
</intent-filter>
</activity>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With