SettingBar click event interception

Next we look at another case, two entries as shown on the screen above, select the vehicle and the originating site selection, they share a common characteristic is common to have a title, content, and the right haircut button, this case we will wrap it into a combination of custom view to display it, we now look at its

Renderings:

The needs of users is this: When users click on the selected entry vehicle he will jump up to another page, the user clicks on the site of the incident Enter the time that you can enter text information, that there is two needs a non-editable state in the entire entry to be clicking for event interception, another editable event, please click on the pop-up soft keyboard input required to enter text, that is, when clicked does not need to be passed directly to the interception son View EditText, it is clear that we need an entry in the custom settings can be edited whether the switch, when in the non-editable state, when clicked intercept the event, when editable, events may continue to distribute down .

Key Code:

class SettingBarView the extends RelativeLayout {public (http://www.amjmh.com)
@Override
public boolean onInterceptTouchEvent (MotionEvent EV) {
// when in the non-editable state to intercept the event, otherwise the event would continue to distribute down
return! isEdit;
}
@Override
public Boolean onTouchEvent (the MotionEvent event) {
// event when the intercept time to put its own root circulated View, click event in response to a global
return layoutSettingBar.onTouchEvent (event);
}
}
. 1
2
. 3
. 4
5
6
7
8
9
10
11
12
well, today's two small cases to finish, and demand is very simple, practical operation by these two cases, we have further deepened the understanding android event distribution mechanism, the complete project case I have to share the code on github, and use of the process have any questions, please leave a message at the bottom of the article, the next we are talking about a more complex case, to further help you understand the application distribution mechanism in the event of actual combat in development.

Guess you like

Origin www.cnblogs.com/ly570/p/11369959.html