Reputation:
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
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
Reputation: 6653
On Mac:
Right click on your package
New -> Other...
( or Command + N )
Choose: Android -> Android Activity, click Next
Select a template (i.e Blank Activity), click Next
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