I want to delete the entire "General" section in the settings, but I do not know how to safely do so. I'm afraid there will be errors in the SettingsActivity.java file that I have.
To clarify: In my new android studio project, I am using a pre-made settings activity, and the activity has several pre-set preferences. I want to delete the pref_general.xml preference because I don't need it but I'm not sure if just deleting the .xml file will be enough or error-free. Hope this helps.
you can delete it but in Preferences Activity you must delete this class:
and properly remove this line (line №1):
Related
I have a big problem. Last I copied a CardView with RecyclerView from a video. After that I created a new empty activity, but the Javafile didn't want to accept the corresponding XML file. And if I go with ALT + ENTER he suggests to me to create your xml file, but afterwards he tells me it already exists. So I can open the XML file, the program recognizes it but it is not recognized in the Java data and I cannot select it there either. There a screen shot, There a picture from solution research, And There a photo of the xml File.
Can someone help me there? Thank you in advance!
I was facing the same problem but you just need to close your project and open it again, the error related to activity file will bee removed!!Just try it.....
maybe you need to rebuild your app
1- Build > clean project
2 - Build > Rebuild project
I hope it will work with you .
Delete those two files. Copy the code first.
Go to File ->new activity then create that activity and paste the code there, besides those lines.
I am trying to rename my eclipse android project. I have tried Android Tools -> Rename Application Package. It gave me an error occurred see log.
I can't find any logs and suddenly this happen my project structure shows some blank and garbage packages as shown in picture.I tried deleting it but deleting them deletes my source code too.Any idea will be very helpful..
You can rename classes, packages and projects by right clicking on the class/package/project and choose: Refactor -> Rename. Check the Update references box to make sure all references to the project/class are also changed.
This behavior is totally ok.
A java package corresponds with an folder.
When a package/folder is empty eclipse will show it as "white boxed" without content (no arrow).
Example:
The class "AClass" in "com.me.pckg" corrensponds with
com/me/pckg/AClass.java
This means folder "com" and "me" contains no files. Eclipse represents this a "white boxed" packages (com and com.me). Package "com.me.pckg" is not empty.
Aware eclipse does not show the package structure NOT as hierarchical as you expect it in a file system view.
Vice versa if you put some file/-structure in your project eclipse will show new folders a packages. This happens after a refresh or a restart of eclipse, the later may be perceived as a sudden action.
If you want to change the type in "com.demo.alaramdemo" use Pieter12345 answer(, or just change the name of the folder in the file system)
If you want a more file system like view within eclipse use the "Navigator"-View
Finally i got the answer to this, With the help of a post above by Stefan
and a solution mentioned here on below link http://www.coderanch.com/t/105581/vc/Eclipse-hide-empty-packages
actually i had to create filters available on a inverted triangle in package explorer header.
In that u have to check filter of empty package , empty parent package etc
it worked for me.
Thanks all for the help ... :)
I wanted to create a Fragment in Android Studio, so I did the following steps:
Right click on package
New -> Android (Other) -> Fragment (List)
Checked both include fragment factory methods? and switch to grid view on large screens
The description said "Creates a new fragment containing a list that can optionally change to grid when on large screens."
Here's the funny part: As I was reading the code to understand how this switching is done, I could not find any code that switched XML files or anything. The only odd thing that I found is that the XML used for the Adapter was called R.layout.fragment_item, but there was no XML called like that in my layout folder.
There were 2 XML called R.layout.fragment_item_list and R.layout.fragment_item_grid. So I though "hey, maybe internally the framework auto decide if going for _grid or _list and that's why it doesn't mark R.layout.fragment_item it as non-existent"
When I was done reading the code, I deleted both R.layout.fragment_item_list and R.layout.fragment_item_gridfrom my layout folder and guess what? R.layout.fragment_item is NOT marked as non-existent, and there is no such file inside my Layout folder.
I already went Build > Clean and Build > Rebuild Project and it still marks it as existent. Am I missing something here? sounds like there is some basic stuff I haven't taken into account.
Just found what was going on. Inside values/refs.xml there was <item name="fragment_item" type="layout">#layout/fragment_item_grid</item> which should be the cause of it.
I had the same issue, I didn't understand your solution as I couldn't see refs.xml in the values folder.
For anybody out there, this is what worked for me:
In Android Studio go to File -> Invalidate Caches / Restart...
I am doing the tutorial for making your first android app and it is saying I need to open the activity_main.xml file in the layout folder.
However, when I open the the layout folder it doesn't have anything in it. There are no files at all.
This is the first bit of programming I am doing. please give me an answer.
Your layout xml files are located in src/main/res/layout/. If they do not show up, you can check the file directory where the project is saved on your computer. If they still do not show up I suggest restarting eclipse and then rebuild/clean. If the problem persists you may need to create a new project
If your files are in the disk folder, but aren't showing in Eclipse, then you'll want to refresh the project contents. You can do that by clicking on your project in either the Project or Package window and pressing F5 (or by right-clicking and selecting the Refresh item.)
It is possible that you didn't create the activity when you created the project and that's the reason you don't see the layout in your When you created the project:
Please follow these steps:
1) Enter your application name in the wizard.
2) Enter Project Name
3) Enter package name.
4) Check mark on 3 items when you clck next "Create custom launcher icon", "Create activity", "Create project in workspace"
5) Again when you click next, Check mark on Create Activity and do next.
6) Make sure that the next screen has all the fields populated. Like (Activity name, Layout name)
7) After all that, click finish.
You must have missed all these steps while creating your project. Try this.
Make sure that the the Activity Name and Layout name are not completely different
I'm using Eclipse. Say I have a project 'ProjectA' in the eclipseworkspace (in a folder ProjectA). I want to copy the project but with a new name (ProjectB) and have all the references in the new project adjusted. I can't find much help for what I thought would be a vary basic operation. I want to try out variations on the original design/code and creating a copy seemed the obvious way to go about it.
Any suggestions please.
Copy your project to a new one (Ctrl+c & Ctrl+v).
Change the package-name in your manifest
Rename your main package with refactor. Don't forget to select.
Change your application name in manifest
application android:icon="#drawable/icon" android:label="**new name**"
I just want to add an item to Mur Votema's list:
5) Don't forget to open the project you want to copy!
It just cost me some minutes to find out that it doesn't work with closed projects. :-)
If you are using Eclipse and all you want to do is clone your Android project and give it a new project name, simply do the a copy/paste (Ctrl-C & Ctrl-V - step 1 in Mur's answer above). Eclipse will ask you for a new project name when you paste and you're done. The Eclipse project name and directory are independent of the application name and package.
Mandatory tasks:
In Eclipse, Copy and paste the project. (Give the project a new name)
In Manifest, update the Package name and save. (Update Launch
Configuration)
Refactor and rename the Package name. (Update references)
Optional tasks:
In Manifest, change the Application label and icon, so after
installing the application on your device it won't be confused with
the first one.
Refactor and rename the java files name, so they won't be confused
with the original project files.
If you have used Encodings such as UTF-8 in your project (in order
to handle languages other than English) you might need to edit
and save those files so their font would be shown correctly.
Note: If you do the 3rd task before 2nd task, some undesired imports would be added to your java classes. You then will need to remove those imports.
There's now an automatic tool for that, part of the ADT.
Make sure the origin project is open in Eclipse, copy & paste to a new name
Right click on the new project > Android Tools > Rename Application Package
Done
As said above all you have to do is copy+paste the project and rename it ["myApp.11"] but sometimes this feature gets bugged in eclipse. One such case happens when you have more than one version of the jdk. to solve this close eclipse rename the older versions of the jdk with an underscore e.g. _jdk17.2
and retry. if you dont need these versions delete them.
Another thing I noticed is that if you leave android:label="#string/app_name" it somehow keeps the original app name when you view the copied app in the list of Applications in Settings > Applications > Manage applications but if you change it to android:label="Your App Name" it seems to work ok.
Also be sure to change your icons properly by deleting the old ones and importing the new ones.
I went to the workspace folder on C:/ (path different for all) copied the project folder (Project A), and pasted it with a new name (Project B). Change the name while in explorer. Then, through Eclipse, made a new android project with the new name (Project B). Different way of doing it.
I Just wanted to add this after struggling with a code i have at work:
DO NOT USE THE PACKAGE NAME EXPLICITLY IN YOUR JAVA CODE NO MATTER WHAT. YOU MIGHT NEED TO RENAME YOUR PROJECT .
EXAMPLES ARE : getResource() and setting the Bitmap source and such and such
it looks like that I had bad references to the package name. it name was used explicitly as a String (e.g "com.pakge.mypkg" ) instead of Context.getPackageName() .
try to reach this method anyways you can 'cos the way i just mentioned it might not work for you... try to reach the method name "getPackageName()" from different other objects.
I have to answer not comment as reputation not high enough - to say that I agree #jengelsma has the best answer, just copy and paste, but watch out for the (hidden) SVN files (in .svn folders)! Unless you want the same references as the other project you don't want these.
Team > disconnect and check 'also delete SVN meta data' on your new copy to do this.
Just want to add some more points :-
Be ensure that the package name must be different for new project and old project if both project are going to install on same machine.
also modify the same in Mainfest.xml
under
I used the eclipse Luna, I tried to copy an existing project (Project_A) as below
Create a new Java project (its name is as Project_B)
Right click on Project_B (to pop up the context menu)
Select the menu item "Import..." (to show the "Import" dialog)
On the list under the "Select an import source" field to extend the item "General"
Double click on the sub-item "File System" (to show the "File System" page)
Enter the path of "Project_A" directory into the "From directory" field (or click the "Browse..." button to find and select the directory of "Project_A")
Check the checkbox of "Project_A" directory under the "From directory" field
To see if the "Into folder" field is showing folder name as "Project_B" (if not, click "Browse..." button to find and select the "Project_B")
Click the "Finish" button (because the Project_B is empty, need not care any more)
The all contents of Project_A are copied into Project_B, we can run the Project_B as the Project_A (if needed we can refactor the Project_B)