user2648429
user2648429

Reputation:

android: create a new activity with xml page

I want to create a new activity. My default has two files MainActivity.xml with MainActivity.java. But, If i created a new activity only .java files are created in /src/ path no .xml files are created in res/layout folder.

Help me to create an activity with java and xml as well ?

Upvotes: 0

Views: 11060

Answers (2)

Hossam Oukli
Hossam Oukli

Reputation: 1306

First create a manually a newactivity.xml in the res/layout folder then after that you can create a newActivity.java like this :

public class NewActivity extends Activity{
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.newactivity);
}
}

Upvotes: 4

Frank Nguyen
Frank Nguyen

Reputation: 6653

On Mac:

  1. Right click on your package

  2. New -> Other...

    ( or Command + N )

  3. Choose: Android -> Android Activity, click Next

  4. Select a template (i.e Blank Activity), click Next

  5. Enter Activity Name (i.e NewActivity), click Finish or Next

By this way, you can create java class, xml file, add information to Manifest file, create new string in strings.xml, create new menu, etc...

I hope this will help :)

Upvotes: 2

Related Questions