I made an android app but I wanted to start a new activity (.xml). Normally when an app starts it shows direct the activity_main.xml layout file. I don't know how that is going on so what's the code for this because so I know how to start a new activity.
Asked
Active
Viewed 152 times
-2
-
then you have to improve your search. There are a lot of tutorials available. – nano_nano Feb 17 '14 at 16:11
-
@ BenjaminStrike normalley u can write code for intent – Amitsharma Feb 17 '14 at 16:12
-
I understand it is about creating a new screen? http://stackoverflow.com/questions/3690851/android-creating-a-new-activity-in-eclipse – Gimer Feb 17 '14 at 16:12
3 Answers
0
You can specify the layout you want to show in your Activity using setContentView method:
setContentView(R.layout.layoutForYourActivity);
This has to be specified inside your onCreate method

Luciano Rodríguez
- 2,239
- 3
- 19
- 32
0
Simple u have need in main activity :-
{
(R.layout.main_activity);
Intent intent =new Intent(getApplicationContext(),AnotherActivity.class);
startActivity(intent);
}
and then you have create `AnotherActivity.class
and insert another layout for AnotherActivity in (R.layout.anotherlayout);
that solve

Amitsharma
- 1,577
- 1
- 17
- 29
0
Create a new activity through New -> Other -> Android -> Android Activity
A activity is a .java file, the .xml is only the layout. Call the new activity with
intent = new Intent(main.this, YourActivity.class);
startActivity(intent);
I suggest you to do some basic tutorials.

Krystex
- 147
- 1
- 8