This question already has answers here:
android: what is the difference between focused, enabled, pressed, and selected states?
(2 answers)
Closed 7 years ago.
I found a tutorial to create android custom button :
http://developer.android.com/resources/tutorials/views/hello-formstuff.html#CustomButton
What is the differences between pressed and focused
And please tell me a focused condition on this button. because I couldn't find any condition which can make this button turned orange.
This question has already been answered here. Please thoroughly search stackoverflow, before posting a question: android: what is the difference between focused, enabled, pressed, and selected states?
I am basically pasting the answer here for your convenience.
"Enabled -> User Interaction possible.
Disabled -> User interaction not possible.
if you hover the mouse over a widget, it is focussed
If you make a press-down (half click) on that widget, it is pressed
If you press-down and press-up while the mouse is at the same position, it is selected"
You can focus buttons without clicking them. This was a bug in a application i developed recently. I set them to be focusable: then the first click on them was just focusing the user on the button and the second was actually triggering the onClick event. This is not so good user experience, but I imagine there might be cases where this is useful.
Related
I don't know if this has been asked before. I am going to be building a calculator for my dad. He asked me if there is any way to have customization with the buttons.
I have not done any code yet. I plan on trying a few things. My research has come up with nothing.
This is what I am trying to accomplish, I have a feeling it breaks the android studio law of coding. This is the concept:
Imagine the calculator. You have 8 blank buttons above the numbers. Those buttons ordinarily have the functions such as percent and sqrt.,..etc.
I have been asked if it's possible can he just hold the button and change those functions at will.
So the question at hand is. Can I do if statements to change the symbol and the code for a particular button when long pressed?
The concept of the calculator would be in portrait mode he can customize the buttons to the functions he uses without having to turn the calculator in landscape mode?
So in theory you have a long press which would bring up a selector. He can select any math function and based on that function the symbol and code would change and the button will work properly to the new selection?
I was going to to build the calculator as a standard. But was also wondering myself if this is possible. I know the buttons serve as a one function but in coding anything is possible.
Any help or advice would be appreciated. If this can be done it opens new possibilities to app features to only show what you want and not a predefined controls.
*******once I try a few codes I will edit question to better see the issue and what I am trying to do.
OnLongPress show a dialog with the option you want and change the button text according to selected option.
On Onclick check the button text and call function according to the text
This question already has answers here:
How to set up a listener on the selected text in TextView
(3 answers)
Closed 1 year ago.
i want a Help just which way i follow to get a listener for the selected text in TextView,
what i want is when the user select a specified text, a button of options will appear.
i hope you help me
Have you tried ActionListener? It will be called when user interacts or performs any action on that particular component. You can get the selected content by component.getSelectedText() or similar method. Do not write separate listeners for mouse and keyboard operations as it might interfere with one another and cause problems.
This question already has answers here:
Will Runnables block the UI thread?
(4 answers)
How to update swing GUI from inside a long method?
(3 answers)
Closed 3 years ago.
I'm facing a strange behavior from the Java Runtime(VM) when I'm trying to display a label or progress bar on the screen when something happens.
The scenario is like this:
the user will press a button to do a certain action
this action is a kind of process on the DB which could take some seconds
I'm displaying a message in a Jlabel field which is already in the form but set to be invisible when the form opens.
Then when the user presses a button I'm setting this label to be visible and do some processing and then set it back again invisible as it was, which is very simple logic.
problem is the Jlable is displayed after the processing is done and not before.
The same problem with happens also a progress bar.
Any explanation why is this happening?
here a sample of the code
Mylable.setVisible(false); defaullt status when the form opens
Event Occurend (user clicked a button)
Mylable.setVisible(true);
....... do some process here
Mylable.setVisible(false);
This question already has an answer here:
Creating multiple identical text verify listeners in eclipse-rcp/swt
(1 answer)
Closed 8 years ago.
I have an application which I want to develop in SWT, and I was wondering if there is a possibility to use a single Selection Listener for multiple buttons. For example I have a menu bar which contains an "open" menu item, and I also have a toolbar where I have an open button, can I use the same listener for both? I would be glad to see just a simple example if there is a possibility, and an explanation if there is no possibility to do what's above.
In general it's possible ... your listener will have to check the event's source attribute to determine where the event was fired from.
If you're attaching the listener to different object's, you probably want to implement a generic Listener instead of an object specific listener.
I keep seeing "focused" and hearing about "focusing" within the development of Android apps. My question is: What is focusing, and how is it applied within Android apps? Is it important? What can you do with it?
I'm sorry if this has been asked, I looked but didn't see anything that clearly explained it. I've looked the the Android development guide, but I couldn't find a decent explanation of what it is and how it works.
Focus is simply giving a specific view "focus", or attention.
One example of using focus is if you have an EditTextView and you want a user to be able to type into it as soon as it is displayed, you would give focus to that EditTextView and the keyboard would automatically be displayed in accordance to typing in that view.
If you've ever used a blackberry and browsed the web via that, you'll remember that whenever you scroll the wheel you sort of select random elements on the page until you find what you want, then click enter. You know what element you're selecting when the elements change colors, or become focused. That's essentially what's happening with 'focused' on ANdroid, except it's mostly used for when you're scrolling via some kind of buttons, or when you select a textbox or something and it's waiting for input.
It is just referring to the view that is active. For example, if you have a TextView and it is the active view then it would be in focus
Simply put, an object/item that has the user's attention for interaction is focused. It is a state an item can be in.
Android Dev UI Events