We all know how easily and safely to create a new Activity
. Now I want to know how to remove an Activity
from my project safely.
I've created some activity in my project and feel that they are now needless and I want to delete them. But if I delete manually these files:
The activity's XML file in the /layout
folder
The activity's Java file in the /src
folder
The <activity></activity>
portion from the manifest file
Then,
Right click on each of the file associated with the activity (in Android View), select refactor, then select safe delete. This will also tell you if there are any use (of that file) which makes it not safe to delete.
You can right click on an activity->Find Usages(Alt+F7). You will get a list of files where the activity is used in the project, and then delete.
ViewGroup vg = (ViewGroup)(myView. getParent()); vg. removeView(myView); should do what you want as far as correctly removing the View from the Activity.
I found my answer. To remove an activity, let the name of the activity is activity
:
activity.java
file from src
folder (java/your.package.name
folder for AndroidStudio)activity.xml
file from layouts
folder (layout
folder for AndroidStudio)activity.xml
file from res/menu
folder (this is an optional folder)<activity></activity>
block of the activity from the manifest
file<activity>
block in the manifest
file has a reference (usually in android:label
tag) remove the referenced value (usually from values/strings.xml
).According to answers from @ojonugwa ochalifu and @Md Tarik Mahmud you should also right click on app folder then Refractor -> Remove Unused Resources
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