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 :)
Related
I'm trying to create a listview where each item in the listview has two lines of text and a radio button at the end, so you can select one of the items in the list and then click next.
simple_list_item_2_single_choice.xml does exactly this, and it is integrated into android.
I have already used simple_list_item_2 which is built in for android on another screen without problems, and I can see that simple_list_item_2_single_choice is in
...\android-studio\sdk\platforms\android-20\data\res\layout
but when I try to reference it in my code, I get the error: cannot resolve symbol 'simple_list_item_2_single_choice'
Does anyone know how to make my app recognize this inbuilt file?
Does anyone know how to make my app recognize this inbuilt file?
Step #1: Copy the file into your app project.
Step #2: Reference your copy from your Java code.
While that layout file may be part of Android, it is not part of the Android SDK, as you will not see that resource listed in the android.R.layout package.
http://i.imgur.com/x0Cbzv5.png
I'm not sure why the 'totalPlus' id won't show up.
I've fixed the mismatch naming problem that the picture shows. Still no luck.
Have you tried cleaning the project or even restarting Eclipse itself?
Also, there may be some other problems/errors in your res folder that can affect the proper R.java auto-generation.
If those do not work, try to insert your textviews via the Graphical Layout and then rename them by right-clicking on them and select "Edit ID". This should do a proper re-factoring.
You can also take a look at the official Layout guide here .
I added grid layout to my project at the start and eclipse added a bunch of stuff. Now, though I am not using this layout. I want to remove it.
I can see the following from my properties file:
target=android-18
android.library.reference.1=../gridlayout_v7
When I remove the line
android.library.reference.1=../gridlayout_v7
I get compile errors relating to my R.java class.
I cannot seem to find a proper way to remove this package. Anybody knows how to do this?
Thanks!
#Nightshadow please right click on project and select properties and then select android now you will able to see Library pane in below area from there you can remove grideview layout library
My content assist was working for Eclipse XML (android) until I did an update of the android sdk, now the "design" of my xml files isn't a graphical view and when I use CTRL+space, I always get these four non-usable suggestions:
"default namespace - Default namespace attribute",
"noschemaLoc - no namespace schema location",
"schemaLoc- XML schema location attribute",
"xsinsp - XML schema namespace"
I also installed dreamweaver which may have interfeared with the XML extension.
A suggested solution is to right click on the .xml file and select choose another program called "Android Layout Editor". But I can't find it anywhere, I think it might not be on my computer.
I have also tried changing workspace without any success.
Any suggestions how to fix this ?
Right click on xml file and select openwith option and you can find Android Layout Editor.
If your content assist is working for java but not for xml, go to window-> preferences->xml->content assist and:
set the delay to 20 ms instaed of 500
set the suggestion strategy to LAX
add the entire alphabet to prompt when these characters are inserted: <=:azertyuiopqsdfghjklmwxcvbn
These are the things that worked for me, and programming with content assist is so much easier
;)
Update to ADT 16 which came out yesterday; the bug should be fixed there. ("The bug" being the bug that in ADT 14 and ADT 15, many newly added XML files would end up being assigned to the default XML editor instead of the customized Android XML editors.)
Re-install the SDK android-platform that you are working with. The resource files may be corrupted [e.g. android-sdk-windows\platforms\android-10\data\res\values\attrs.xml].
It's android sdk problem just change android currently version to another one
like if you are currently using android 2.3.2 than change it to android 2.3.3 i have tested it's currently working fine!!!
You can change it through PROJECT->PROPERTY->ANDROID now on that change version
Or you can set the default editor in Eclipse Preferences, used Android Common XML Editor.
You find it in Eclipse Preferences, General, Editors, File Associations. Click on .xml, choose "Add" "Android Common XML Editor". Select it and press the Default button.
very helpful i am jut following Step
click on xml file-right click on file -then choose the Android Layout Editor.
Is there any way to make Eclipse + Android SDK + ADT Plugin offer some sort of auto-complete in XML files if I hit CTRL+Space when my cursor is in a spot such as the ones marked with an * below.
<LinearLayout id* ... lay*>
The thing is that I think that the above was actually working already directly after the initial install - even though it of course never worked within style files.
<style name="ActionBarWrapper" parent="Fill_Parent.Vertical">
<item name="android:layout_height">36dp</item>
<item name="a*"
</style>
There is an icon in the eclispe toolbar to directly access the "new android xml file" wizard.
You could use IntelliJ IDEA instead of Eclipse, it has full auto-completion and works well for Android development.
http://www.jetbrains.com/idea/
The Community Edition fully supports Android, and is FREE
The latest ADT plugin (r9) does have partial auto complete feature in the layout xml.
for example, if you type ctrl-spacebar while the cursor is between 2 tags, you get the list of all avaliable tags (views and layouts). If your cursor is inside a tag, you get a list of all avaliable attributes.
First of all: Thanks for the good advice everybody. Not sure if the following should be an answer or a comment. Going for the answer because comments do not allow enough characters.
After trying out some eclipse plugins (like Rinzo XML Editor ) I found out that it actually worked for some files while it did not work at all for others. After some testing I am now under the impression that there is a difference between creating XML files via...
New > XML
and
New > Other > Android > Android XML File
I double checked that even when both files have exactly the same content (xml-version, encoding, namespace etc.) they behave differently with regards to auto-code-completion depending on the way of file-creation. I also checked the file properties but could not make out any significant differences. Obviously it must be something local or some meta stuff I am overlooking.
I think the different behavior is because when you create the file using "New->XML" the wizard opens the file using the default associated editor to xml content.
If you create a file using "New->Other->Android->Android XML File" I think the wizards tries to open the xml file using a specific xml editor, instead of the one you have configured as default, in this case Rinzo I guess.
In the second case why don't you try finding the xml file in either "Package Explorer" view or "Navigator" view, right click on the xml file and selecting Rinzo through the "Open With" option.