Is there a way to disable the xml warnings? - android

I just did an update of my SDK and now eclipse is giving me all sorts of totally unwanted warnings in my xml... for example I have a RelativeLayout that doesn't have an id or a background (it's actually a transparent button) and eclipse is warning me that it's a useless element. Is there a way to turn this idiocy off?
TIA

According to the documentation at http://tools.android.com/recent/ignoringlintwarnings you do this by including the tools xmlns:
xmlns:tools="http://schemas.android.com/tools"
And then adding a tools:ignore annotation in the relevant elements:
<RelativeLayout
tools:ignore="UselessParent"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="30dp"
android:layout_centerInParent="true">
This still works perfectly in 2022.

In New Update of Eclipse ADT Plugins will give you New Tool Which Name is Lint here is one SO Link for this tool and it's advantages .Click Here
Now for Disable xml Warnings that are come from Lint Android Tool ,you need to go
Window-->Preferences-->Android-->Lint Error Checking
in this Dialog you will find all Issue for Xml in android and you can make disable it ,if you want to disable.And Make sure you will not disable usefull lint warning because it's help us to find there are multiple ID assign in xml and lot more..

Related

Why is my layout preview in Android Studio empty?

My issue is similar to this but Android Studio doesn't tell me anything about a rendering issue or compiler/build errors(I was able to build fine).
Here is what I am seeing(this is a new project)
And the contents of content_main.xml
After reading on different rendering issue threads, I I've tried rebuilding, cleaning, invalidate caches/restart and even starting a new project to see if the layout preview was working(Still empty)
I also played around with different sdk versions(20,19) to see if the layout preview was working but all I got was this quirky issue that I don't think would cause the layout preview to not work.
Does anyone know what my problem is here? I didn't mess around with my initial Gradle files and remove any support library dependencies. Another solution I had in mind was reinstalling Android Studio but that's last resort.
Just check your sdk valid version like example.
Try putting your TextView element into an empty FrameLayout:
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/my_groups" />
</FrameLayout>
This code above should be put inside your RelativeLayout. Hope it helps.

Tools namespace android listitem

I'm trying to use the "tools" namespace feature in Android Studio.
I'm trying to populate the ListView with dummy list items, for design purposes. The link here says the tools:listitem="#android:layout/<filename>" should do.
But for some reason, Android Studio keeps showing Layout android:<filename> does not exist. I'm trying to find a solution for it, so I don't have to run my app again and again with dummy values for testing.
I might be overlooking something very foolish, so forgive me. Here is what I have for now:
<ListView
android:id="#+id/controllerProfiles"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="20dp"
tools:listitem="#android:layout/profiles_list_item"/>
And I have a file profiles_list_item.xml under res/layout. Any suggestions or alternatives?
you should change the following line :
tools:listitem="#android:layout/profiles_list_item"
to this :
tools:listitem="#layout/profiles_list_item"
with #android you say that you want to use a layout from android resources but your layout is in your own project files.
tools:listitem doesn't work with ListViews in Android Studio 2.2. This is a known bug. I've tested this in Android Studio 2.3 beta 1 and it is fixed here.
You can also move from ListView to RecyclerView as this bug doesn't occur at RecyclerViews.

Android Studio: Error parsing XML & URI is not registered

After adding a new Activity to my project I get following error while compiling the layout
Gradle: Error parsing XML: not well-formed (invalid token)
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/tv_password"
android:text="<password>"/>
</LinearLayout>
"http://schemas.android.com/apk/res/android" is marked red and hovering pops following message up
URI is not registered ( Setting | Project Settings | Schemas and DTDs )
My Settings>Project Settings>Schemas and DTDs look like that:
I already found some similar questions around here but nothing helped me to solve this issue. I hope someone has an idea... :)
I was having a similar issue. However, the comments did not assist me in the solution to this issue. This answer from this question actually solved my problem.
Summary:
Go to "File > Project Structure > Modules", click "add" and then click "android" and "apply/ok". That should solve anyone having a similar problem but the comments for this question are not helping you.
For me, the problem occured when I created my own subfolder for old code.
Specifically, Android Studio threw an error for all layout files that weren't in the default folder ../res/drawable/, but instead placed in my own subfolder ../res/drawable/backup.
I got the same error for a long time and none of the answers I found online really helped me, or probably I wasn't looking the right way. At the end what I found out was the way I named the directory. So, I was trying to make the landscape layout for my app and named it layout_land. That kept showing me the URI is not registered error. I just had to change the directory name to layout-land.
Summary: No underscores in directory names!
My issue was creating new resource directory for some animation work. The files were .xml and I chose file type as "xml". I got this problem. Changing the file type to "values" and the problem went away. No idea why, could someone explain this to me? I'm using Android Studio on an iMac.
GO to settings >Language&Framework >Schemas&DTD
here add Uri used in your code.
Some special characters not allowed here.
Directly to assign text then with warning
android:text="value"
#string file from get then avoid warning
android:text="#string/hello"
res/values/strings.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello!</string>
</resources>
For me this problem was gone when I have made following changes to my project structure on Android Studio.
file->project structure ->SDK Location -> enable check mark for "Use embedded JDK (recommended).
Hope this will help someone.
First thing is go to the project folder in the Android studio and check for any folders which are created by you. It will show this error if you have created any folder on your own.

Text in XML Graphical Layout appears as strange characters

I am having issues viewing text in the graphical layout section of my android applications. This is consistently happening across many projects, new and old. See the link for visual example: http://i.imgur.com/OwENudf.jpg
The button in the image should say 'test' but instead its two boxes. Sometimes it appears as an open bracket, [
Background- I was having issues with eclipse/android sdk not creating the R.java file when a new project was created so I uninstalled the sdk and then reinstalled it. The R.java file builds fine now but the text in the graphic layouts is all strange characters.
Any idea what I can do to fix this?
The XML has one warning, which is 'Hardcoded string "test", should use #string resource"
I don't think this is the issue because I have had this error before on working applications.
EDIT:
XML code-
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="#dimen/activity_vertical_margin"
android:paddingLeft="#dimen/activity_horizontal_margin"
android:paddingRight="#dimen/activity_horizontal_margin"
android:paddingTop="#dimen/activity_vertical_margin"
tools:context=".MainActivity" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginLeft="18dp"
android:text="test" />
</RelativeLayout>
I believe you are having font issues with your emulator. It can't find appropriate characters to display. You may need to reinstall that.
Ok so I searched and I think it will fix your problem (and it was too long to post it as a comment).
Go to the platforms folder where android-sdk is installed (C:\Program Files (x86)\Android\android-sdk\platforms).
Then go to the folders you're currenlty building your projects with then go to data/fonts (i.e C:\Program Files (x86)\Android\android-sdk\platforms\android-8\data\fonts) and take a look at the file fonts.xml. Also, may a ttf file disappeared when you updated your ADT (which seems odd).
You can find here an example. Read this carefully before trying to modify these files.
I hope this will solve your problem. If not, I have really no idea about what to do.

Android Layout Editor Freaks Out on Question Mark

This is strange, yet I see it all the time as I have lots of reasons to display just a simple question mark in this app.
When editing with the Eclipse graphical layout editor, everything is fine...until I tell a TextEdit or a Button to display just a question mark. Here's my code:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
>
<TextView
android:id="#+id/test_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/question_mark" />
</LinearLayout>
And the string is defined in res/values/strings.xml. The relevant line is:
<string name="question_mark">\u003f</string>
The error message I get is:
Missing styles. Is the correct theme chosen for this layout? Use the
Theme combo box above the layout to choose a different layout, or fix
the theme style references.
Couldn't find theme resource for the current theme
Change the text, and the error message goes away.
You can see that in my struggles, I'm even trying to use the unicode version of a question mark. And yes, \? doesn't work either.
Note that this only happens when the graphical layout editor is set to API 7 or greater.
Now the graphical layout editor displays the question mark properly, and the emulator and my phone display the question mark without any problems. I'm just annoyed with the error message taking up 1/4 of my screen for all my layouts (and obscuring other error messages that may crop up).
Any suggestions?
First, test this again on the ADT 21 release that shipped today.
If the problem continues, create a sample project that demonstrates the issue, and post it along with step-by-step instructions on the Android issue tracker.
Well, this is a really crappy hack, but it kind of works--if you stand on your head!
You can use the unicode \u00bf as in
<TextView
android:id="#+id/test_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="\u00bf" />
It's not a normal question mark, but it's close enough for a hack and gets that annoying error message out of your hair. And it might even increase the humor quotient of your app!
But PLEASE, if anyone out there has a real fix, post it!
Wow, I entered a bug report...[time marches on]...finally, I get a few emails as the Google team starts to look at it.
Today, I received some good news. It looks like the bug has been fixed (and they found a few related bugs, which have been fixed as well). The fix will be in the next release, Version 21.1 Preview 2. You can read the official details here.
Looking forward to it!

Categories

Resources