Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

New activity without xml layout in Android studio

When I create new Activity class in Android studio , two XML layout files will generate automatically.

One of them have same name with my Activity and other XML file have name like : Content_[activity name].XML

Now, how can i turn off this auto generating work in Android Studio?

I want to create new activities in android studio without any XML layout file.

like image 588
sam Avatar asked Dec 19 '22 18:12

sam


2 Answers

Follow these steps

1) Right click on your package name in which you want to create Activity.

2) Move your mouse cursor to New->Activity->Empty Activity.

3) Click on Empty Activity. you will see following window. "Unmark Generate Layout File"

enter image description here

4) Click Finish

Done...!!

like image 112
vabhi vab Avatar answered Dec 21 '22 11:12

vabhi vab


If you don't want Android to Studio to generate the xml files for you, You must do every steps on your own.

  1. Create a java class which extends from activity.
  2. Create a layout resource file.
  3. Override OnCreate method in your activity and set your layout.
  4. Add the new activity in manifest.

That's it.

like image 34
Midhun Vijayakumar Avatar answered Dec 21 '22 10:12

Midhun Vijayakumar