How to get class/method/attribute info in Android XML file? - android

When I am in a Java class file, I can get context info of a certain method/attribute/etc. (in IntelliJ, this shortcut is Ctrl+Q), which is basically a short help file describing what that element does. Look at the image 1.
But when I am in an XML file, I cannot get any contextual info on any element. Look at the image 2.
How should I enable it? Do I have to download some additional Android doc (javadoc?) file?

For Android code support in Eclipse, you might want to checkout http://android-developers.blogspot.com/2011/06/new-editing-features-in-eclipse-plug-in.html.
In particular :
XML editing has been improved with new quick fixes, code completion in more file types and many “go to declaration” enhancements.

basically a short help file describing what that element does
FYI: It's called Javadoc.
For the xml:
Go to Window, Show View, Other, General, Properties.
Then, when you have opened an Android xml, you can switch to the Graphical Layout. Clicking on an element will show you it's properties in the property view. Hovering over the elements there at least will give you contextual information.

As CrazyCoder suggested, there is no way to get such contextual info because of the lack of sources to fetch such info from. Until better times...

Related

What is the point of `Content_main.xml`?

To my understanding, the content file is just the xml files contents...but in a separate file. Whats the point?
I've seen
What is the role of content_main.xml in android studio 1.4?
and there doesn't seem to be much documentation about content_XXX.xml, so I was wondering, why did the new update include the default creation of this file?
Why divide the code into two files, why not just put all of the contents in its own xml file, I've tried it...and it works. I fail to understand why the content_main file is generated on creation of a new project.
Can someone give me a list of benefits of why I should be using the content file?
Thanks,
Ruchir
activity_main.xml is used to display coordinatorLayout, tabLayout, floatingActionButton, viewPager etc.
content_main.xml is used to display your stuff i.e. what you want to display to users.
for more details check my answer here.
Update after conversation in comments below: The point of doing this is to bring in more organization in the code. We can always go forward with the old way of putting everything in one file. Android Studio is just giving us a start with keeping the layouts in a more organized way to allow easy comprehension of code and reuse wherever possible, by segregating related stuff.

Flat Ui in Android Studio

I am using Flat Ui in my Android Application using Android Studio but i am unable to find AutoCompleteTextView inside Flat Ui and I have to use AutoCompleteTextview in my application so anyone suggest me the way to use that?
I Just fork a library for AutoCompleteTextView and waiting to be merged.
For now:
Inside library/src/main/java/com/cengalabs/flatui/views create new file name it FlatAutoCompleteTextView.java
Find the FlatEditText.java copy the content and paste it to FlatAutoCompleteTextView.java
Inside FlatAutoCompleteTextView.java replace all text with "FlatEditText" with "FlatAutoCompleteTextView" .
find this part style = a.getInt(R.styleable.fl_FlatAutoCompleteTextView_fl_fieldStyle, 0); and replace with style = a.getInt(R.styleable.fl_FlatAutoCompleteTextView_fl_autoFieldStyle, 0);
Edit library/src/main/res/values/attrs.xml , paste this code inside and save or just replace content with this http://pastebin.com/w4w5UWdd
To use style fl_autoFieldStyle="flat" or fl_autoFieldStyle="box"
If the Flat UI project does not support AutoCompleteTextView, your choices are:
Write it yourself.
Convince the author of the library to write it for you.
Hire some other developer to write it for you.
Go without AutoCompleteTextView.
Go without Flat UI.
Since none of the Flat UI widgets are based on AdapterView, creating an AutoCompleteTextView may be rather complicated.
The merge request from PinoyWebDev (thanks to him) is closed and AutoCompleteTextView is now available in the library. You can see the added class here.

Where can I find a list of Android style items?

Where can I find a list of all possible items in an android style xml? It seems like a single reference document listing them and summarizing what they do would be an extremely useful thing to have bookmarked, but I can't find one anywhere.
Here you go for every attributes you want in single file: https://android.googlesource.com/platform/frameworks/base/+/refs/heads/master/core/res/res/values/styles.xml
And If you want only attributes list then you can refer R.style xml directly but It's not well documented so It would be better to view actual source code given in above link.

Complete reference of Android XML styles

Google's Android documentation is relatively complete when it comes to classes, interfaces, and such. But I have not been able to find a complete reference of all the style-related XML -- not just backgrounds and padding and whatnot but also action bar options, etc. Does such a thing exist or is it really just scattered amongst the other docs?
It doesn't really show all of the options contained in each style in the docs, but just has a reference to the tag.
I find that using GitHub is the best bet :-\
As an addition to hwrdprkns answer, I would suggest the Android Resource Navigator for Chrome. It's an extension that allows you to type "arn" in the URL bar / omnibox and then begin searching whatever resources (XML styles) you want. When you click on any of the results it will ink you to the GitHub when you select one.
https://chrome.google.com/webstore/detail/android-resource-navigato/agoomkionjjbejegcejiefodgbckeebo

Any possibility to get autocompletion / type-ahead / intellisense in Android XML Files (Eclipse)

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.

Categories

Resources