'Applying an event based on whether a button is pressed or not via touch input
I am planning to develop an Android application for blind people. The application will interact with the user only after they touch any part of screen. The application will start with a voice (I am going to use Text to Speech) and will wait for touch input; if the user don't touch the screen, the next option will be vocalized instructions for touching the screen.
To clarify: "Please tap to screen to do X" - if user touches the screen after this sound, X will be done, else they will hear "Please tap the screen to do Y".
For example the button will be disabled at the beginning, after vocalizing information, button will be activated for 3-4 seconds, if there is no input, button will be deactivated again. However how can I give different jobs to one button? Is that possible? Should I use a timer?
I'm also planning to create a screen size button, but I could not find a proper way to do this. Any tips?
Solution 1:[1]
You shuld create a LinearLayout, put the button inside it, and use something like layout_width="match_parent" and layout_height="match_parent" in your XML to make the button occupy the full screen.
Then disable / enable the button from your code as needed.
Solution 2:[2]
Of course you can introduce different jobs for your button. In your case you simply can have an int variable that you can increment it each time it enables so you know how many times button has pressed and with a switch you can test that variable and run different operations.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | JonasCz |
| Solution 2 | Morteza |
