I'm new to android studio. I was a bit confused with the following code.
EditText emailEt;
if(!Patterns.EMAIL_ADDRESS.matcher(email).matches()){
emailEt.setError("Invalid email address");
emailEt.setFocusable(true);
}
What is the purpose of this setFocusable() method?
what will happen if the boolean value passed was set to false?
If you're not sure of what focusable is, here's a brief explanation.
If there's a form in a view, there can be 2 cases -
The keyboard comes up automatically, or when you hit the next/enter key on the keyboard the next input field is selected automatically for receiving the input
You need to manually press an input field to bring the keyboard for typing. And on hitting enter, the keyboard might just go away.
The above phenomenon is called Focusing.
Getting back to question, if you want the case (1) to occur, then you set setFocusable() to true, else if you want case (2) to occur, you can set it to false.
Reference the below docs for more info
setFocusable - View | Android Developers
android:focusable - View | Android Developers
difference between focusable and clickable - StackOverflow
I don't think it is much useful but it helps in request focus to next edit text when the next button is pressed android keyboard
Related
when I select a widget say a Text widget in android studio, I hit on alt and enter to generate a code. For example, you can wrap a widget inside a column with this combination but in my case, this combination suggests me things like : generate getter and setter or toString() method which definitely come from java. Now you might say, you have to change your key binding then but that is the problem, on keyboard shortcuts section, I see only one section where I can assign a combination. But then this happens where I only get code suggestions for java. How could I possibly change that?
Alright, so I found the solution, when you check the keyboard shortcuts, you gotta find show context actions and assign a key binding to it, then it is fixed.
In Android Studio, pressing the up an down arrows will change the contrast of the autopopup bar.
Before
After
This also occurs in the default themes. Is there anyway to make the contrast start in the after position, even without pressing any arrows?
The popup is dimmed to indicate that there is no default selection for completion. It depends on context and in some cases the first entry will be selected automatically, while in the other cases you need to select the completion varian with the arrow keys first.
To get the pre-selection work automatically in IntelliJ IDEA and Android Studio enable the Insert selected suggestion by pressing space, dot, or other context-dependent keys option:
In some other cases it may be also necessary to add
-Dide.completion.lookup.element.preselect.depends.on.context=false
in Help | Edit Custom VM Options and restart the IDE.
Related issue: https://youtrack.jetbrains.com/issue/IDEA-193090.
I use Android Studio 3.01, it will display the wrong hint "Expecting member declaration" when there are some problem with my code.
But the text information of the wrong hint is hard to copy, it will be disappear immediately if the mouse is out of the hint area. I hardly to select the text of hint and click Copy item from Right-click menu.
Is there a simple way to do it? such as keyboard shortcuts.
Add Content
Many times that both the error hint and keyword hint are displayed simultaneously!
You may take a look to this question :
How to copy error message in Android Studio tooltip
which contain the answer:
Once popup shows up, move your mouse pointer over it and simply select (mark) bubble's text, then do Copy with keyboard shortcut (CTRL+C on Windows or Command+C on Mac) while still having mouse pointer over the bubble.
I’m currently writing an MFC dialog app which has a menu. The menu displays correctly and the menu entries work correctly via mouse, accelerators, and hotkeys (e.g., to quit: Ctrl+Q or Alt+F,Q).
Unfortunately, the Enter key doesn’t seem to work. That is, pressing Alt+F will open the File menu and pressing ↑ will highlight the Quit entry, but pressing Enter will not select it.
I know that using menus in dialog apps can be a bit tricky, but I’ve done this successfully before. However, that was a long time ago with a customized VS wizard, so I am trying to remember how to do this from scratch. I tried checking my old code, but could not find anything in reference to VK_RETURN. (No, there’s nothing special in PreTranslateMessage.)
These two questions are related, but they want the dialog to receive the key, I need the menu to get it.
Does anyone know what the problem is and how to fix it?
Do anyone know why FocusOut event is not working on linux?
I have 1 enabled textbox and 3 disabled combobox.
I bind the textbox with FocusOut event where it will call a proc that enables or disables the 3 combobox.
It works perfectly on Windows. However, it doesn't seem to trigger the FocusOut event when this action is done on Linux. One weird thing is that if I click on buttons, FocusOut event seems to be triggered.
Could it be because my combobox are disabled?
But why does it work on Windows?
I really hope someone can help me please.
Thanks in advance.
I have observed in the past that some window managers steal the focus temporarily from Tk on each button click before setting it back; I suspect that this has to do with the way that key event handling works, but I am unable to check at the moment (due to being on OSX, where things are different). Because of the complexities involved, I'd suggest that if you bind to <FocusOut>, you should also check whether you get a <FocusIn> event shortly after; a little extra delay (e.g., 0.1s) before doing the update of the buttons' disabled status will not hurt.
Or you could hang the code to do the disabling off the entry widget validation engine, perhaps like this:
.e configure -validation focusout -validatecommand doButtonEnableDisable
The validation interface is the same for both the old style entry and the new style ttk::entry widgets. It's also supported by spinboxes. Just be aware that you need to return a boolean true from doButtonEnableDisable or you'll reject the change to the entry, and you should take care to ensure that your code does not produce an error or it will disable itself; the docs list the things to watch out for.