Android Studio: name of keymap/shortcut that displays method parameters hint? - android

Using the latest version of Android Studio.
Once you type the function name and open brackets, AS would automatically display hint with variable type and name (which is really handy). But sometimes it would just disappear.
Does anyone know the keymap (shortcut) that would trigger it to pop again? (haven't found one in AS options, may be I missed one). In particular, I'd like to know the name of the corresponding shortcut so that I can find it through the Preferences screen and update the assigned keys if necessary.

The command name is "Parameter Info".
On Mac, it's assigned to Command+P by default.
On Windows, it's assigned to Ctrl+P by default.

And It's form View menu, called Parameter Info. There is the shortcut on menu.

To display a dropdown version of all the available parameters, you can use Ctrl + Space to show a dropdown list.

Related

Shortcut key to find global variable inside a project in android studio

What is the shortcut key to find that where is the particular global variable Initializing in android studio project.
Place your cursor on the variable and then press Alt+F7 for the Find Useages command. In the Find Usages result, look for "Value write". Expanding that category will show all the places where the variable is assigned, which includes initialization.
If you middle-mouse-click any of your variables it takes you to the delcaration. If you middle click it again, it pops up a window with every usage. Alt+F7 works too.

Template Proposals in Android Studio

In Eclipse, I can put my cursor on a method name and hit ctrl-space and I get a list of available template proposals.
In Android Studio, when I'm typing a method name and open paren, I get a list of template proposals, but afterwards, how do I see the list again? I've already got show quick doc on mouse move, but that only shows the method signature I selected at first. I want to see alternatives to what I selected the first time through.
How do I show alternative method signatures, aka alternative template proposals?
EDIT:
Thanks to AndroidMechanic for answering Ctrl-P.
Here is what it looks like in Android Studio:
Here is what it looks like in Eclipse: . Notice that you're presented with the documentation in Eclipse, which I find helpful. But Ctrl-P gets me most of the way there.
In android studio to see all method overloads click inside the parenthesis and hit Ctrl + P. This will show you the different combinations you could pass as parameters to a method.

Android Studio rename attribute or method not always working

In Android Studio, I sometimes have to rename some field, attribute or method name.
I know I must select its name, then hit Alt+Shift+R. Then I type in the new name, and hit Enter.
However, sometimes it works, and sometimes... it just does nothing at all. The new name is just discarded and replaced with the old ones.
Can someone explain me why and how to force this very basic feature to work ?
I suspect that you've missed the refactor preview window that shows up when AS finds some code that it doesn't know if it should be refactored or not. For example, if the method being modified is referenced in comments, then AS will ask if you want to refactor those comment as well.
using a shortcut for "Rename" Variable Shift + F6
or
Select Variable/Method name -> Right Click in java file -> Refactor -> Rename
This also happens when using dagger and trying to refactor via Shift+f6. Android Studio hesitates when renaming things in generated code (which seems silly). Anyway, doing a project clean and then doing the rename works.
Alt+Shift+R replace a selected String (in your case the selected field, attribute...) and doesn't rename the variable, field... itself.
The feature I use for that task is Rename (not Replace). To achieve that you can either use Shift+F6 or right mouse click > Refactor > Rename. Now it changes the name also in other classes (if necessary).
For me, every time I refactor>rename it was showing me the usages and I changed them manually, but the name of the java class stayed the same, even I changed all the usages.
Finally, I unticked all the boxes, and it worked.

Break on variable value change in Android Studio 1.1.0?

I know I could set a breakpoint at every line where my code changes the variable, but is there an option such as right-clicking a variable (to "Add to Watches") that would stop when a variable changes value?
I think C++ has this option. See this.
And Eclipse? See this.
Is this implemented in AS?
You can break on value changes of some variables in Android Studio 1.1.0.
Android Studio calls them 'Java Field Watchpoints'.
From the breakpoints windows, (Run -> "View breakpoints...") or Ctrl+Shift+F8,
you can add "Java Field Watchpoints" from the plus in the top left corner, and then select your class and variable.
If the goal is simply to set a watchpoint where execution halts if a variable's value changes, there are two methods:
Pressing Ctrl-shift-F8 to set a watchpoint brings up this dialog:
That looks more powerful but it's confusing because it lacks the option I need; and there's an extra step: filling in the dialog box below:
Once you fill it in correctly, you get the same options for stopping execution as in the simpler method below:
Define the variable on one line ending with a semicolon.
Left-click in the area where you set a normal breakpoint and up pops a dialog box.
Choose options to suit your needs.
Any instance where the value of the variable prefDbExists changes, execution will pause as at any "normal" (unconditional) breakpoint. And that's all I needed when I asked the original question.
EDIT: Fully qualified class name is {package name}.{class name})
What you seek for is commonly known as "WatchPoint".
You will find detailed answer and examples on the doc. page of JetBrains - IntelliJ - Idea which is the basis for Android Studio.
https://www.jetbrains.com/help/idea/2016.3/creating-field-watchpoints.html
For me this works perfectly !
Add a Kotlin Field Watchpoint by clicking on the space next to the line number for the field declaration in Android Studio. Select Kotlin Field Watchpoint from the Set Breakpoint menu. You will now get a breakpoint whenever that value changes.

Eclipse content assist in Android xml file like IntelliJ

When editing android xml files.
IntelliJ allows me to complete android:screenOrientation by typing a:sc then I get my tag first in list.
In Eclipse, I have to type android:sc before I get my tag on top. If I type a: in Eclipse it empties list.
Is there a workaround or setting?
You can type sc only and press Ctrl+space.
Eclipse will suggests you the list of tags that starts with android:sc.
No need to type android:s to get the tags which starts with s.
this method used to work for me.
But for some reason when I press Ctrl+Space now, eclipse auto complete without popping the proposal window, and without understanding the context.
(if i'll type for example si and press Ctrl+Space eclipse will complete the word to a word starting with si instead of suggesting android:textsize as it used to do)

Categories

Resources