Reprinted from Http://www.cnblogs.com/xiaoweiz/p/3833079.html
First, let's look at the definition of touch mode. It is a state of the view hierarchy when the user interacts with the phone. It's very easy to understand,
Represents whether the most recent interaction occurred through a touchscreen, because there are other ways of interacting on Android devices, such as d-pad, scrolling balls, and so on.
Why is Android introducing such a mode? This is because of interaction, design considerations, when the user directly uses keys or trackball with the UI
When interacting, you must first make the target control focus (such as highlighting) so that the user will notice what control is receiving input. However, if
If the device supports touch gestures, the user taps the control directly with his finger, which of course does not necessarily highlight the target control (that is, get the focus).
For a device with touch-screen functionality, once the user taps the screen, the device immediately enters touch mode. The control that is clicked at this time
Only Isfocusableintouchmode () is true to gain focus, such as the EditText control. Other controls that you can touch, such as button
(Their isfocusableintouchmode defaults to false), and when clicked, they do not get the focus, they simply perform the onclick event.
Whenever a user clicks on a key or scrolls trackball, the device exits touch mode and a view is placed on it so that the user
You can then interact with the UI without having to touch the screen again. Touch mode is effective throughout the system (across activities), any
You can call the View.isintouchmode () method to see if the current device is in touch mode.
From the above introduction we can see that the view under the touchscreen, set the Focusableintouchmode and not set in the user experience is different,
In fact, the internal processing logic is also different, such as: The control does not set this property will not get focus when the user touch interaction, that is, focus in
The touch process is not changed, but its onclicklistener is triggered when the up event arrives if it is set up. And if you set the Focusableintouchmode
property, its behavior is to first try to get focus, if it succeeds, its onclicklistener is not triggered, only when you click it for the 2nd time.
Before the Onclicklistener is executed. Some students may have encountered this problem in development, StackOverflow has a similar problem:
Http://stackoverflow.com/questions/20473355/button-is-not-calling-onclicklistener-with-first-click?lq=1,
Everyone can refer to the following. Since setting this property will cause inconsistencies with normal Android interaction, Android recommends that we use this property conservatively,
Think twice before you're sure you want to use it, and make sure you've read the article about touch mode in Android Developers blog:
Http://android-developers.blogspot.com/2008/12/touch-mode.html
On the issue of inconsistent behavior after setting this property, we will mention it again during the processing of the touch event in the back, when we can
Angle to see why.
Android Touch mode and Focusableintouchmode analysis