I have a question about the hierarchical view of eclipse. With some projects my com.example.test packages suddenly split where normally it would be on one line instead of three. It looks like this:
Does anybody know why this happens?
How can I get the com.example.test on one line again?
Edit:
I want the package presentation to be hierarchical, I only want the com.example.test back on one line.
I finally found the answer. It isn't folding because on mac there are hidden files (.DS_Store) and eclipse doesn't ignore these files, so the folders are not empty.
To fix this you have to exclude the DS_Store out of your project:
Right click, Properties
Expand Resource and click onto Resource Filters
Click "Add"
Use these settings Filter type: Exclude all.
Applies to: Files
Click "All children (recursive)"
File and folder attributes: Name matches .DS_Store
If you have done this, your project will have normal hierarchal view with com.example.test.
Found the solution at: http://twigstechtips.blogspot.nl/2012/10/eclipse-ignore-certain-files-in-project.html
Tip: Use Android Studio, it works so much better!
In the Package Explorer "View Menu" (the down arrow), select "Package Presentation" > "Flat".
Related
In my project I want to add a menu bar. I have downloaded a menu icon now I want to add it under .Android -> Resources. Unfortunately I can't add anything (a prohibition sign appears as a mouse icon). I also tried to add only a png or another file which also does not work.
My project
The downloaded icons:
Does anyone know how I can add the files in the appropriate place?
Don't know if this is the case, but some times the projects lacks the actual 'Drawable' folder. Create the folder yourself from fileexlorer
I want to remove the middle part from the package name.
Ex: com.example.app to com.app
I have tried few things but not able to remove the middle part of the package name without errors.
I think that the only you can achieve that is this:
Press Ctrl+Shift+R, set Text to find to com.example.app, Replace with to com.app and hit Find, All Files.
After that open the directory com in file manager, move app up in hierarchy, so it becomes com/app and remove example directory.
There is a much better way to do this. com.example.app >> com.app
In Android Studio,
1) Open your project pane (tab on left top) select Android option.
2) In the same pane click on the gear icon and uncheck "Compact Entity Middle Packages".
3) Expand your package hierarchy in Project pane.
4) Now drag the package app (the one you want to move) on the package com (where you want to move).
5) You will see a red boundary around the com package now drop package app.
6) A popup should appear select "Move package", next enter com package path, next select do refactor.
Done!!
Please note, different Studio versions have different options but drag and drop method remains the same
Android Studio indirectly (but easily) supports this requirement;
e.g. Change java.X.Y.myPrecious to java.myPrecious [assume packages X and Y are empty]
(a) Select Android from dropdown heading in Project window.
(b) Using the 'gear/cog' tool uncheck Compact Empty Middle packages
(c) Drag myPrecious to java (be patient if necessary)
(d) Right-click/Delete X
(e) Clean and Rebuild the project making any obvious changes to the Manifest if necessary.
click on Setting,in setting click compack Empty middle package
then click on your package :-> Refactor->Rename ->ok
-if you package is not devided into more then 3 sub directories best way is to just rename them. Refector -> Rename -> done.
-But when you what to remove the empty one you shoud set structure to
android-> compact middle package -> now move you files to the desired folder
-> remove the empty ones now -> Done
Click with right button in your packet and find REFACTOR.Inside It you have the option Rename and after clicking a window will appear to confirm you with warnings.
Try it!
Basically, You need to move the entire below files to precedent package.
Suppose..
Package: com.app.example.food
if you want to delete example from package.
Move com.app.example."food" directory to com."app" directory directly
Done.
I am trying to create a new folder inside the /res directory
I added a new directory
The folder does not appear in the /res folder even though it exists in the finder
Case and point I tried adding the folder again and I got a message telling me it exists.
If you can suggest what I can do to fix this I'd love it!
(And yes I have restarted the program as well as my computer)
Turns out there is a selector at the top which, by default, is set to show Android. If you flick the toggle down to 'Packages' you can see your own packages.
In Android Studio you can add new directories by right clicking the resource folder in the Android view. (Don't get confused by the New Directory option.)
For example, if you want a new layout resource file and folder then right click layout and choose New > Layout resource file.
If you want a new layout-sw600dp for the activity_main.xml file then choose Smallest Screen Width from the list and click the >> button. Fill in the file name and width and click ok.
Android Studio will automatically create the layout-sw600dp directory and in the Android view you will have both layout files conveniently displayed next to each other.
It is a similar process for adding other resource directories and files (see my other example).
Clicking at TAB Android in top, select the perspective Project Files. Then u can see all folders of project.
Android 4.0
The Android view by default seems to conceal the duplicated resource type directories in the side panel.
If you want to view the duplicate resource type directories i.e. drawable for two different languages,
switch the view from "Android" to "Packages" or "Project" or "Project Files"
Browse the actual folder structure in windows and you'll see the folder. Put the same resource file found in the normal drawable folder into this new directory. Then when you go back into Android Studio you'll now see 2 files under the NORMAL \res\drawable structure. Make sure you don't look for a subfolder in Android Studio called "drawable-sw600dp" because you won't find it other than in windows explorer. What you will find in Android Studio (after you copy the resource file) is a new resource file along with your original called "jenny-web.png (sw600dp)" or something similar. This same principle resolves the same error when working with other resources like layouts.
For Android Studio 3.0, those who are following https://developer.android.com/training/basics/supporting-devices/languages.html and have encountered the same issue as the one stated in this question, you can also do the following aside from the above answers which are helpful.
Right click to the target folder (i.e. res folder) > New
Choose Android Resource File
Specify the file name, and in the Directory name field put the folder name you want to create or the existing folder you want to put the resource file.
After hitting OK, in the Project files dropdown, you will see the correct strucutre.
And in the Android dropdown, you will see it as part of the strings.xml under values folder.
This worked best for me. What I did was I right-clicked the 'app' directory and chose 'New' >> 'Android Resource File'. After that I filled in the File Name with 'strings'. Chose 'XML' as my resource type and my Directory Name was 'values-b+za+ZA'.
This created everything as I wanted it to, however, values-b+za+ZA, still didn't show in the Android view but it shows in the Package view. (The views you choose from the top dropdown.)
The difference this time is that in the Package view I can still see my new 'strings.xml' file and in the Android view I van also see the new 'strings.xml' file.
I guess android studio doesn't show custom directories in the Android view but creates like some kind of link to the true directory when working with it. I am not familiar with Android Studio at all but this did work for me. If there are more professional answers please feel free to correct me.
You most probably have the file named in Uppercase, Android Studio does not recognize file names in Uppercase, I had made this mistake a while back.
As the developer doc states:
be sure the Project window is open (select View > Tool Windows > Project)
and the Android view is selected from the drop-down list at the top of that window.
You will then be able to see all relevant project files (including new ones) in a more efficient way.
Hope it helps someone.
This is odd but in my case i had to many underscores delimiters.
When i renamed yt_search_view (2 delimiters) to yt_searchview (1 delimiter), it appear in project view where it should be. It is probably a bug. My version is Android Studio 3.2.
Also, i notice that if i add a value folder to the layout folder, it also fix the issue.
Example:
layout_control_x
--layout
----top_panel.xml
--values <--adding this empty folder fixed the problem
For complete information on how to add sub folder layouts check this.
Is there any quick way to know if an image is referenced or used in a Java class or XML layout? For example like if an image.9.png is used in a certain layout. Thanks.
in Eclipse you cam make Search Like below Step .
First Click your Current Project in which you would like to Search .
Now Press Ctrl+H in windows that will open Search Dialog Window.
Now you want to check bg.png used in your Project ,Search like below in
#drawable/bg
This will search for all Layout and xml file which use this image.
Now for Search in java file you need to search with it's id which you give in xml file.
R.id.yourimageId
Now in your case you can search your #drawable/image by Ctrl+h Dialog in Eclipse.
EDIT In ADT updated version Like ADT 16 we have lint tool it will give all warning for unused Resource .
Issue: Looks for unused resources
you will find this warning in lint check .
for More about Lint Refer this Link Lint Checker SO
There's no way to do it via code. However, in Eclipse, if you delete the image (make sure you make a copy first) and build the project, you'll know the spots where you are missing it :)
I thought ADT should come with a visual editor for building GUI : Easy way to build Android UI?
However, I just cannot find it. I was wondering where is the Visual Editor for Eclipse with the ADT plugin.
I can run HelloWorld application without problem. However, whenever I click on main.xml at the left navigation tree layout folder, here is what I get. What I wish to get is a WYSIWYG editor.
Select your main.xml file. At the bottom of eclipse you can see a Layout tab, click on it and eclipse will open the android gui editor.
As Paul Kearny previously noted, to resolve issue with seeing "Design" tab instead of "Graphical Layout" follow these 2 steps:
1) Delete project from the left of the screen, without deleting the source files
2) File -> Import -> Existing Projects into Workspace, browse and select your workspace folder and open your project
Graphical Layout problem fixed!
If you want to edit the layout visually, rather than through XML, click on the Layout tab at the bottom left of the main.xml window (in your screenshot, just above Problems).
Also note, there are issues with displaying some of the widgets. For example, the ListView does not render. So, my hint is to change ListView to just a View, then work out the details of the layout so you can get the colors, relative-ness, etc. Then switch it back to ListView. There is one other widget that I cannot recall off the top of my head ...
To resolve issue with seeing "Design" tab instead of "Layout" or "Graphic Layout", I had to:
1. Delete the project from Eclipse without deleting the source
2. Shut down and restart Eclipse
3. Import the project back in
You could probably skip step 2, but I did it just to make sure.
Hope this helps anyone else who has the same issue.
If your view is showing Design|Source for the .xml file right click on the main.xml and select open with - android common XML editor. Simple.
If it is happening to one particular xml, you can delete the file (make sure you copy the content first), create new xml and paste the content again.
I recommend that any serious Android developer stay far, far away from Eclipse/ADT Design View. This is a time-wasting tool that sorely lacks the attention it would need from Google to make it worth serious consideration. It doesn't render the views as a real device would. There is no way to bind dynamic data. Does it work with fragments (I think not)? For it to work properly and have useful features would weigh down Eclipse further and make it unacceptably slow. In my very humble opinion, the entire strategy for ADT's ui-design tools has failed.
Thus, the recommendation is: edit Android XML layout files by hand and use the only reliable testing mechanism you have for layouts: actual devices. You can always fallback on the emulator - but the emulator performs 50x - 100x slower than an actual device. I'm not exaggerating. Pick your poison!
new fix, took me forever to get this fixed, really simple....delete the xml file and undo the deletion (ctrl+z), double click and there you go. Hope this helps someone as it did me. No shut down required.
If you see "Design" tab instead of "Graphical layout", just close the project and open it again.