Android Studio's quick doc pop-ups are buggy and occasionally unreliable, but one oddment in particular seems to occur all the time, which suggests it is a 'feature'. Behold:
Note the window title, 'Documentation for [string literal]' -- why would Android Studio consider a string literal to be a potentially javadoc documented code element? Can I disable this behavior without affecting legitimate quick doc pop-ups (e.g. those for field and method names)? Worse, sometimes Android Studio will place the doc window somewhere above the cursor (not pictured) so it obscures my view of the relevant code. Can the position of the quick docs window relative to the cursor be configured somewhere?
To answer your last question, the position of the documentation (quick docs) pop-up can be fixed:
When it is displaying, click the push-pin icon in the top-right of the pop-up to "Open as a Tool Window".
On this new tool window, click the gear-with-dropdown icon and uncheck "Floating Mode".
The window is then docked to the right side of the window by default but may be re-positioned or returned to a pop-up.
Related
This question is kind of difficult to put in words, but I want to know how to toggle between the dimens/strings id's vs their actual values. The IDE is IntelliJ. An image should make it a bit more clear what I'm asking:
Upper image is actual values, lower image is with full id displayed. If you click on the 60dp, it will then display the full id. I'm interested in how to then revert it back to the original 60dp. I've spent some time trying to find it online and but couldn't find anything. I know that I could always just do a "go to declaration" on the id and find the actual value in strings.xml, but it would be significantly faster to just read it on the spot. Any other useful IntelliJ/Android tips someone could think of would be welcome too. If you could help me I'd be very happy.
On Windows press Ctrl+> to both expand and collapse when the cursor is within the value/code you want to perform Folding on or just use Ctrl++ or Ctrl+-.
This is called code folding and can also be found under the contextual menu (when you right click on the code) then Folding (See image below)
Is there any way that I can view my print statements in android studio without displaying the time and directory? It's extremely distracting and hard to debug when that text is taking up so much space.
In the Android Monitor view in Android Studio (tested on Version 1.3), in the vertical toolbar inside the "logcat" tab, you will find a gear-shaped toolbar button. Click that, and you will get a "Configure LogCat Header" dialog with checkboxes to allow you to toggle on and off various pieces of what gets displayed:
Uncheck the items that you do not want (e.g., "Show time"). Note that LogCat does not show any "directory" except with respect to something you log yourself. My guess is that by "directory" you are referring to the package name.
This does not appear to affect existing messages, but should affect any future ones appended to the LogCat transcript.
You should use Log.d(tag, message). See here for the documentation.
try to use Log.d("message to show in log console")
Say I type the following field
field = "I am field";
In Eclipse as soon as I place the mouse on field it shows me a list of options from which I can select create local variable field.
In Android Studio, the lightbulb is a headache for me. Sometimes it appears quickly, sometimes it takes forever to appear.
Is there a way to force it to appear?
Are you talking about using Alt + Enter?
This link might help:
https://www.jetbrains.com/idea/help/keyboard-shortcuts-you-cannot-miss.html
Pressing Alt + Enter results in the drop-down menu with correction options in this case:
In the Android studio Settings/Keymap "shortcut Ctrl+Alt+S"
search for usage of "Alt + Ent" as below image if its not assigned for any action plz go for No. 2
Android studio shortcuts
In the Android studio Settings/Editor/Intentions.
Check whatever you want to show Intention in are checked or not as below photo
Intention
Double check no.1 is working fine and you found usage of "Alt + Ent" shortcut
[You can find the solution on official Jet brains website]
Intellij IDEA keyboard shortcuts
Intention actions
Try putting the cursor right next to the last letter of the class/method you want to edit, in other hand what worked for me in Android Studio is to use the bar on the right side, 'Outline' and from there get to the part you want to edit and use the tools from Outline or by right clicking on the method that appears in the tree drop down.
So I want to have a keyboard in my app that has emoji just like Whatsapp or Hangouts. How can I do that? I want to leave my key keyboard as it is I just want to add tabs to put emojis. I would think it would be easily supported by the soft keyboard but I can find nothing so far. Anyone could tell how to do it?
UPDATE:
The keyboard with emoji is included in Android KitKat and can be accessed by long pressing the new line button in the keyboard. The Hangouts keyboard however has the emoji icon visible instead of the "new line" key. If someone knows how to make this the default (either in layout or programmatically) I will take that as the correct answer.
As #dbar pointed out, the answer is:
android:inputType="textShortMessage"
But in my case, I was already using textMultiLine, so I had to use the both of them together:
android:inputType="textMultiLine|textShortMessage"
Looks like this:
I'm not sure about the Exact android version, but this should work only on Android 4.1 and above
Finally the answer was:
android:inputType="textShortMessage"
The new line key becomes a key to take out the emoji keyboard. The only quibble is the 'new line' key from the keyboard disappears with this configuration (before you could long press to choose between emoji/new line but now it's only emoji).
In Google Hangout, the emoji button is not on the keyboard (at least on my phone which is already using a third party keyboard), it's inside of the TextEdit box, and so it's part of the application itself (Gabe, I'm talking about the latest Google Hangout on top of KitKat with emoji support, all the current screenshots I found of Google Hangout do not show what I'm seeing on my phone, so this must be a very recent feature).
This is actually pretty easy to do, placing an ImageButton to the right of a TextView inside a RelativeLayout (the RelativeLayout which is made to look like a TextView with a custom background).
Then, it's just a matter of hiding the keyboard when clicking on that ImageButton and replacing it with a panel full of emojis when that happens (like in this open source emoji android keyboard, which is under a creative commons non-commercial license).
There is no functionality to add tabs to any generic keyboard. Certain keyboards may support it, but it isn't a common feature. You could write your own fully custom keyboard, but that's a lot of work and will piss off many users.
Also, I'm not sure what you mean about by like in hangouts. I use hangouts- it doesn't do anything odd with my keyboard. It stays as Swype, there's no special emoji tab. It may be a feature of your favorite keyboard based on the input type (I assume both use input type textShortMessage). But it isn't a generic feature.
In the system-wide search on my HTC Desire (Froyo), I see a little drop down left to the search input field that allows to select where I want to search (All, web, apps).
How can I implement this in an application of mine? The search tutorial on the Google developer site does not address this.
So in a scenario like the following, taken from the Android docs,
I would like to click on the books and then get some sort of menu to e.g. select "words", "headings" as search mode.
Update: I am not looking for the QuickAction dialog itself, but rather how to attach something to the books icon that reacts on touch, so that I could attach the QuickAction or a new activity or ... And I want to use the standard Android Search Dialog as described in http://developer.android.com/guide/topics/search/search-dialog.html
You can't modify the system's search dialog. So if you want customizations like making a drop-down menu appear when the user touches the icon, you'll have to implement your own dialog. This would make your search non-standard so I wouldn't advise it.
However, if I can't talk you out of it, you can see how Android's built-in search dialog is implemented here:
https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/app/SearchDialog.java
In Android 3.x this gets a little easier with the introduction of the SearchView class.
It is just a custom view that get rendered when you hit that button with a fancy animation.
It has nothing to do with the search framework per se. You just show a custom layout (with a fancy animation if you want) and set a value by clicking on one of the icons. Thats it.
I think what your looking for is called a "quickaction dialog".
Here's a tutorial that should have you well on your way.
Updated by question asker (paste of comment):
ah i see. well somehow you need the id of the icon in order to implement the onclicklistener(). you may be stuck just going with a search widget and implementing most by scratch. Or perhaps, with the search dialog implemented and running, use hierarchyviewer to see if the icon has an id. Maybe you'll be in luck and it'll have a unique one. I'm out of ideas for now.
Those options (and their icons) are determined by the searchable items list in the android settings (Settings->Search->Searchable items at least in my phone). If you want to add a search action to that menu, take a look at this:
http://developer.android.com/guide/topics/search/adding-custom-suggestions.html#QSB
Enabling suggestions on a device
When your application is configured to
provide suggestions in Quick Search
Box, it is not actually enabled to
provide suggestions in Quick Search
Box, by default. It is the user's
choice whether to include suggestions
from your application in the Quick
Search Box. To enable search
suggestions from your application, the
user must open "Searchable items" (in
Settings > Search) and enable your
application as a searchable item.
Each application that is available to
Quick Search Box has an entry in the
Searchable items settings page. The
entry includes the name of the
application and a short description of
what content can be searched from the
application and made available for
suggestions in Quick Search Box. To
define the description text for your
searchable application, add the
android:searchSettingsDescription
attribute to your searchable
configuration. For example:
http://developer.android.com/guide/topics/search/searchable-config.html
Quick Search Box attributes
To make your custom search suggestions
available to Quick Search Box, you
need some of the following
attributes:
android:includeInGlobalSearch
Boolean. (Required to provide search suggestions in Quick Search
Box.) Set to "true" if you want your
suggestions to be included in the
globally accessible Quick Search Box.
The user must still enable your
application as a searchable item in
the system search settings before your
suggestions will appear in Quick
Search Box.
android:searchSettingsDescription
String. Provides a brief description of the search suggestions
that you provide to Quick Search Box,
which is displayed in the searchable
items entry for your application. Your
description should concisely describe
the content that is searchable. For
example, "Artists, albums, and tracks"
for a music application, or "Saved
notes" for a notepad application.
android:queryAfterZeroResults
Boolean. Set to "true" if you want your content provider to be invoked
for supersets of queries that have
returned zero results in the past. For
example, if your content provider
returned zero results for "bo", it
should be requiried for "bob". If set
to "false", supersets are ignored for
a single session ("bob" does not
invoke a requery). This lasts only for
the life of the search dialog or the
life of the activity when using the
search widget (when the search dialog
or activity is reopened, "bo" queries
your content provider again). The
default value is false.
So if you want to add an option to search for words or headings, and you have an activity that allows that search, then you can add that Searchable item(s) to the list. They will be available only if the user wants, though.