What is "focused" regarding android apps? - java

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

Related

Custom button with a selection

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

Android set an Accessibility Focus listener

What I want is to have a listener when a certain element (like a button, an image, a view or anything else) became accessibility focused. I found stuff like mybutton.sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_FOCUSED) but then I don't know what to do next, how to handle it.
My main purpose is to make a sound when an element became focused instead of reading his accessibility name.
Any suggestion?
Im not much of an Android developer, but i think the event you are using is sending information to the screen reader. You would need the opposite of that.
I think the answer to this question could help you
Google talkback API to get current focus item in android
Best of luck, sounds like a cool app for visually impaired children

How to make a button that draws over any screen?

Apps like Floating Toucher or Link Bubble proves how useful a floating button can be. And no, I'm not talking about FABs as per Material Design guidelines here, I meant a literally 'floating' button that draw over any screen in the system that can be dragged around and clicked.
Take a look at these examples:
(source: boatmob.com)
Now, I tried to Google a way to do this but I'm afraid I'm still at lost here. How can these apps draw over screens outside their own?
I've come across this SO question which more or less asking about a similar question. But to be honest, I wasn't able to gain much information from it. Said question mainly addressed how to intercept a touch for a floating view; Not how to specifically make one.
I really hope that somebody out there could enlighten me on this. Thanks in advance for your time!
If you are talking about an activity's view (not Widgets), 'floating' on screen, like Facebook ChatHeads. Then you should create a background service and attach a view with it. Though it is not recommend by Android.
See below links
What APIs in Android is Facebook using to create Chat Heads?
http://www.piwai.info/chatheads-basics/

How to get Java Doc (In Eclipse) to pop up without having to wait for it to popup

I'm more of an iOS developer, so I'm using the analogy of option clicking a variable to get the documentation to popup in xcode. It's quick and snappy.
In eclipse, if I want to read the documentation for a class/variable/method, I have to hold the mouse over the variable like a chump for 1-2 seconds, if I move the mouse I lose it and then it requires waiting again, and doesn't always come back, breaking every law of User experience ever written.
Just wondering if anyone knows the best way to configure eclipse with this stuff, I had a search in the preferences panel but the closest thing I found was hover, but that still didn't address the delay that I must wait when I'm just wanting to write code.
When your cursor is within the item you want to view the docs for, you should be able to open/focus them by pressing F2.

What in Android would allow me to touch the edge of my screen while playing my game and slide over an Item screen?

Android has many useful tools when coming to views and screens and layouts.
Description: While playing my game (running around as a zombie bear eating humans) I would like to allow the player to access an items menu via sliding a menu from the right side/edge of the screen. Or at the least be able to access a game options menu (not game settings which would be the menu button).
What would be the best fit for description?
P.S How would I make a question like this less like a discussion and more like a straight forward programming question when I don't really know what's available to do this.
Also, if this is the case, please point me to another location to ask a question that may require a discussion.
Thank You!
Try looking at the SlidingDrawer class.
PS I personally don't see a problem with how you have worded your question if you are looking for ideas of views/widgets you need to perform a specific function/effect.
My first thought, and for a simple approach (this wouldn't be animated or dragged really), would be using a RelativeLayout where the portion representing the menu was initially set so that it's visibility were GONE, except for a small tab or arrow or something. When that tab/arrow is touched, the visibility of the View for the menu could be toggled to VISIBLE.
With visibility set to GONE, a view is not drawn or considered in any part of the layout pass when the screen is drawn.
You could populate a listview with some icons and when an particular icon is selected, then figure out which one was selected and then execute some function and hide the sidebar using an animation. I've never developed a game, so I'm not too sure how far it deviates from the standard, but I wish you the best of luck :) ! If you post the source let me know would love to test your game and see how you work with the source!

Categories

Resources