I was using quick assist in Eclipse to quickly generate constructors when pointing on an empty space 1 line below a class declaration, after migrating to Android Studio i was hoping i could do the same.
Unfortunately on my Android Studio pressing Alt+Enter while cursor pointing at the first line after class declaration :
doesnt do anything! and i have to right click that postion and generate the ctor the hard and long way or write it by myself, is the quick assist not openning a bug or is it the way it is suppose to be?
if its a bug how can i fix it? if its not, what is the quickest way to generate a ctor?
i Believe you are looking for Alt+Insert.
Related
VSCode have a great option what helps developer to make code more beautiful. I mentioned in the given picture. It indicates each brackets related to which case. I've worked on flutter in VSCode but now I've decided to work on Android Studio for some reasons and unfortunately I don't know where I can find it. Did you guys know how I can fix it?
I have to apologize for Title because I don't know what this option is?
You can also use following command to make more beautiful and easy
(1) Search Everywhere (Press Shift Twice / Press Shift Twice)
(2) Recently Opened Files (CTRL+E/Command+E)
(3) Find Action (CTRL+Shift+A/Command+Shift+A)
(4) Generate Code (ALT+INS/Command+N)
(5) Override Methods(CTRL+O/Command+O)
(6) Delete Line at Caret/Cursor (CTRL+Y/Command+Y)
(7) Collapse/Expand Code Blocks (CTRL+- / Command+-)
(8) Collapse/Expand Whole activity code (CTRL ALT - /CTRL ALT +)
(9) Reformat Code (CTRL+ALT+L / Command+Option+L)
Just Press CTRL+ALT+L on Windows or Command+Option+L on Mac. The android studio will reformat all the code for you. And the good part is that it works for XML layouts as well.
Use CTRL+ALT+L to reformat your code.
Use CTRL+ALT+O to optimize imports.
Use CTRL+ space to complete code.
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!
What i want to do:
Create a custom keyboard, since default keyboards are not sufficient.
Keys needed: 0-9, '-', ',', 'e', 'del' and one empty one where i can put the logo.
I already achieved this in iOS with inputAccessoryView, but after some research i believe there is nothing similar in android. So i decided to go the way of creating my own Keyboard in xml.
Tested Source is from here.
But the XML Designer in Android Studio tells me: The following classes could not be found:
Keyboard (Fix Build Path)
Row (Fix Build Path)
Tip: Try to build the project.
I have no clue what this error is about, and stated tips by android studio aren't doing anything.Any help is appreciated!
EDIT: Ok, to make it clear: Android Studio doesn't know the xml tag "< Keyboard >". Why? Do i need some sort of special import in the manifest file? or sth in the gradle files?
EDIT 2: To make it really clear what happens to be my problem here:
It is possible to do a custom keyboard!
The Keyboard design must be in res/xml/qwerty.xml.
I would recommend you to follow this tutorial, where it is explained how to do it from scratch.
Good luck and hope it helps! :)
Whenever I try to paste some lines of code into a file in Android Studio it acts like this:
Copied lines overwrite existing lines below caret position.
It pastes several times for a single command (I copy 7 lines and press Ctrl+V just once and it gives me 49 lines)
I don't know if this is some weird coding feature that I'm unaware of.
How can I turn this behavior off and make it work the ordinary way?
Update
it's not a keyboard issue. No problem in Visual Studio!
In case someone else should face a similar issue in the future, mine was fixed after I marked and then unmarked Column Selection Mode (Alt+Shift+Insert).
Still strange but it resolved the issue!
I have the same issue I fix by clear android studio cache
File ---> Invalidate Caches/Restart
Another solution
instead using ctrl + v Use ctrl + Alt + Shift + V
Probable Reasons:
You are copying from somewhere where lines are hiding inside compact brackets
Your keys/keyboard is gone might generating 7 times same signal for a command (7*7 = 49)
Please check
In android studio 2.2 or above hold Control key then drag the layout or widget to duplicate
Press the 'insert' button on your keyboard (labeled "ins")
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