I updated Eclipse and SDK and now in every xml file the TextViews have the warning "Consider making the text value selectable by specifying android:textIsSelectable="true"".
Is it possible to hide the warnings, I hate to have my project with a lot of yellow exclamation marks.
Go to the propeties of your project. Go to Android Lint Preferences. Search for SelectableText and change the severity to ignore.
You can also do this in Eclipse preferences for all projects.
There is a good reason for this warning. By just disabling it, you are basically ignoring user interface guidelines of Android and you are not using the full potential of the user interface of your app. Therefore looking at each text view and explicitly setting this attribute to either false or true will increase the quality of your app.
Related
I'm not sure if my question is worded correctly, but it's easier to show an image to explain my question.
In the XML editor, some values are replaced with the actual values that was defined for that entry. However, I don't want Android Studio showing me the actual values. Instead, I still prefer that it showed the reference names. So, how do you disable the editor from previewing in this manner?
In the image below, android:text="#string/sign_up", but the editor is showing it as android:text="Sign up...", as well as other attributes, and the reference name only shows up when I mouseover the attribute.
How to disable this feature permanently via Android Studio setting/configuration?
Update: Same thing is happening in .java files. Enums or R.string constants are being replaced by their actual values.
For Java files you can go to Preferences->Editor->General->Code Folding and uncheck "Android string references" but this only applies to code not to xml layouts
– Oleg Bogdanov
I fought with this for hours! Having the values show up instead of the references is great, in most cases, but I was working with a project imported from AIDE and its layouts were a mess. I need to see the references, not the values. I found the "possible duplicate" link above, mentioned by zombie, but it didn't work (or so I thought).
Finally, after reading this post, I tried unchecking the "Android string references" again, but this time I restarted Studio after (even though I wasn't prompted). If you have the same problem, the solution above should work, but save yourself (possibly) hours of aggravation and:
Restart Studio after unchecking the "Android string references" setting!
BTW, I would have added this as a simple comment, but SO wouldn't let me!
IntelliJ IDEA has an inspection that checks for spelling. In the analysis overview, I can see how many spelling mistakes were found, e.g. 12 typos found. In the code they are highlighted using a wavy green line.
However, I find it very hard to look manually for those wavy lines. Is there a keyboard shortcut or a search function which will automatically skip to the next highlighted typo?
F2 and Shift + F2 shortcuts will navigate you to the Next / Previous highlighted error. You need to configure the error navigation first to Go to next problem instead of default Go to high priority problems option(from the context menu of editor right side bar):
See help for details. Another option is to use double click (F4 shortcut) from the Inspection Results window to go to the source.
IntelliJ IDEA 2016.3
If you want to fix all typos from the project, you can list all of them and iterate through them using double click (or F4 to open the source):
Analyze > Run Inspection by Name...
Type "Typo"
You will be able to see a list containing all typos grouped by file:
In Settings -> Editor -> Colors & Fonts -> General, you can add an 'Error stripe mark' color to Typo.
With the default settings of IntelliJ I find it difficult to spot the typos. So I do the following hack to spot and correct them once in a while.
Temporarily change inspection setting to show Typos as Errors.
IntelliJ then highlights the typos as Errors, making it much easier to spot them in the editor. I correct them and then revert the inspection setting changes. The changes can be kept permanently but I don't prefer that!
I'm using butterknife library to my project to use Bind annotation instead of findViewById.
when I use #Bind(R.id.button) Button mButton;
but never use it, android studio show me warning that I never used it and highlight it with yellow.
when I press Alt+Enter for quick fix -just exploring- and choose the secound choise
suppress for feilds annotated by 'butterkife.Bind'
the warning is gone, but then when I tried to undo what I have done it does't work what ever I tried.
I know it's small thing but it's really annoing.
Open up your Android Studio preferences, and go to Editor > Inspections.
If you want to simply reset everything to the defaults, you can stop here and click "Reset to defaults" under the settings icon to the right of the search box.
If you want to just reset the one inspection, from this list find the inspection that you want to configure. The inspections you have changed should be highlighted in blue. It sounds like you are looking for the "Unused declaration" inspection.
Depending on the inspection, you may see either a "Configure annotations..." button at the bottom of the pane to the right, or a pane that says "Additional special annotations." If you see the button, click it. From the list of annotations, click the minus sign below the pane to remove the exception for that annotation.
If you prefer editing the raw settings files, you can also find your custom inspection rules at <project>/.idea/inspectionProfiles/Project_Default.xml.
Android Studio should be known for those in most cases just aggravating Lint "Using left/right instead of start/end attributes" warnings. I'm using Android Studio 0.8.9, but the following problem was also present in earlier versions: If you add this ultra-minimal snippet anywhere in your code
public enum BiteMeLint {
LEFT
}
Android Studio shows the warning
Use "Gravity.START" instead of "Gravity.LEFT" to ensure correct behavior in right-to-left locales.
This also happens for the constant RIGHT, though it suggests to use Gravity.END in that case. Now I'm a developer who likes to keep his code completely clean of any warnings, either by complying or, if that's not possible, by suppressing and putting a "todo" or "fixme" where necessary. Here, since I'm using "LEFT" and "RIGHT" as constants for actual directions, the warning is obviously a bug. Sadly, adding
#SuppressLint("RtlHardcoded")
doesn't remove the warning. So how do I remove this joke of a warning? And now that I'm asking, can I somehow completely disable RTL warnings for a project I'm sure will never launch in a right-to-left locale?
According to this issue tracker, it is a bug which was fixed in Android Studio 0.8.10 recently.
The option to disable this inspection can be found under Project Settings | Inspections | Android Lint | Unsing left/right instead of start/end attributes. So you can simply disable it for the whole project by unchecking the box.
Android Studio 3
Go to File > Settings > Editor > Inspections > Android > Lint > Internationalization > Bidirectional Text.
Then uncheck Using left/right instead of start/end attributes.
But...
You may not want to actually disable the warning. It is there for a reason. Read what the Android Studio description says about it:
Using Gravity#LEFT
and Gravity#RIGHT can lead to problems when a layout is rendered in
locales where text flows from right to left. Use Gravity#START and
Gravity#END instead. Similarly, in XML gravity and layout_gravity
attributes, use start rather than left.
For XML attributes such as
paddingLeft and layout_marginLeft, use paddingStart and
layout_marginStart. NOTE: If your minSdkVersion is less than 17, you
should add both the older left/right attributes as well as the new
start/right attributes. On older platforms, where RTL is not supported
and the start/right attributes are unknown and therefore ignored, you
need the older left/right attributes. There is a separate lint check
which catches that type of error.
(Note: For Gravity#LEFT and
Gravity#START, you can use these constants even when targeting older
platforms, because the start bitmask is a superset of the left
bitmask. Therefore, you can use gravity="start" rather than
gravity="left|start".)
In the manifest, disabling the android:supportsRtl attribute will disable the Rtl lint warnings for the whole module
android:supportsRtl="false"
Sometimes my code moves on its own or just disappears in the Eclipse XML editor.
When I highlight the affected code, the highlighted lines try to correct themselves. But when I scroll or drag the mouse in the opposite direction the code shifts again. In essence I will have repeating, missing, and broken lines of code being displayed from an otherwise error free file. The files affected do compile and if I close / re-open them this problem goes away, for the moment. Any ideas on what's happening?
Addition:
Jeff Axelrod provided a link to a new bug report with Google.
This bug is (finally) fixed in ADT 21. The fix is now available in ADT 21 Preview 9, posted a few minutes ago, here: https://android-review.googlesource.com/#/c/44936/1
The reason you get weird visual artifacts is that if a file contains broken DOS line endings (multiple carriage returns without a newline for each carriage return), Eclipse gets very confused. That's Eclipse issue https://bugs.eclipse.org/bugs/show_bug.cgi?id=375421 .
There are two parts to the fix:
(1) First, ADT was fixed such that it no longer introduces these \r\r sequences into the document. This makes sure that you don't get new documents which triggers the weird editing behavior, but it does not retroactively fix older documents with these line endings, so if you open them, you still get weird editing behavior.
(2) Second, there's a new lint check which looks for broken line endings in documents. This runs incrementally, so if you edit an XML file which has this problem, ADT will add an error marker for this problem -- along with a quickfix to perform surgery on the document to fix it.
In short:
Get ADT 21 Preview 9; run Lint on your projects and look for any complaints about files containing broken line endings, and if it finds any, apply the quickfix. From now on, further edits with the layout editor should keep the files consistently formatted.
FYI, the relevant fix is here: https://android-review.googlesource.com/#/c/44936/
Instructions for easily updating SDK Tools and the Eclipse ADT plugin are here: http://tools.android.com/preview-channel
-- Tor
(from the Android tools team)
After some tests, I have found that the option "Automatically format the XML edited by the visual layout editor" (in Preferences | Android | Editors) might be the culprit here.
With my tests, I've found that changing a property (such as the layout_gravity) while in Graphical Layout design mode always screw up the visual display of the file when I go back to the XML (text) mode when this option is ON but that I have no problem when it's off.
If you want to format the XML upon your return from the Graphical Layout design mode, simply use the shortcut Ctrl+Shift+F. Also, I didn't see any problem with using the option "Format on Save"; even when I use it in the Graphical Layout mode; so you can use Ctrl+S instead while you're still in the Graphical Layout mode to both save and format your XML.
I've tried other editors options like "Show range indicator" or "Use characters to show changes in vertical ruler" but I didn't see any difference in behavior with activating or de-activating these options.
Finally, to correct the visual display of the file when it's corrupt; I found that using the shortcut: Ctrl+A, Ctrl+C, Ctrl+V is a little easier than closing/reopening the file. This is equivalent to making a Select All, Copy, Paste; effectively copying the whole XML file over itself.
Still experiencing this bug on Juno (Eclipse 4.2.0, ADT r20).
My fix:
Go to Window -> Preferences -> Android -> Editors.
I have both "Format XML using the standard Android XML..." and "Use Eclipse settings for indentation...." checked. This solved the problem for me.
EDIT:
contain faster method, so it was bring to top:
Ctrl+F -> fill like that:
"Find" "\r\r\n"
"Replace" "\r\n"
Switch "Regular expression" to ON
hit the "Replace all" button
Ctrl+A
deselect text.
be happy =)
Original was here:
Just don't hide that issue, if you may fix it. Some times even closing the XML file didn't help.
For fix it let's look at the reason of it. First of all Turn On "Show Whitespace Characters" (Window > Preferences > General > Editors > Text Editors > Show whitespace characters )
Then back to your XML-file.
In scaled image you may see the difference of "\n"-symbol colors;
then just put cursor to that symbol, which is more dark.
look, two lines was selected 0o... that's may be the reason!
so just delete it, and press "Enter" or "Return" button for add "\n" symbol.
Hope it help you.
also you may find the other symbol of endline:
Just delete it too, and your XML will have a great look!
P.S. sorry for hyperlinks, i'm newbie and on SO i can't upload image or more than 2 links. so hope you'll get the point without additional pictures ;)
P.P.S. Thx to guy who vote up, now i can provide this with images.
I had the same difficulty and finally found the solution: Right click in the editor, select Source/Cleanup Document.
I had the same issue. The following steps were the solution. Link suggest its worked for others.
Go to Preferences -> keys
Unbind copy, paste, and cut (hit "apply", then "ok")
repeat step 1
Restore unbound commands from step 2 (I didn't restore cut, but I'm sure you'd be fine)
Notice there are 2 bindings for each of the 3 commands
Unbind secondary function for both copy and paste (leave ctl+c/ctl+v [copy/paste] bound)
At this point you should only have 2 bindings set to perform copy/paste (i.e., ctl+c/ctl+v)
Hit apply -> OK
This solution was found here.
When this bug appears with new versions of ADT (which are mandatory for fixing and where bug should not appear often) just use Lint tool to fix it..
Find it in Lint warnings and click yellow bulb icon in upper right corner of that Lint warnings list..
Hope it will help somebody