Last night debugging a night, on the LinearLayout to receive screen action, but there is a problem, the following code is the code I tuned
</pre><pre name= "code" class= "java" >private int pressedarrow;public class Onsettertouchlistener Implements Ontouchlistener {@Overridepublic Boolean onTouch (View V, motionevent event) {Float pt = event.getx (); switch (EV Ent.getaction ()) {Case MotionEvent.ACTION_DOWN:if (pt > Last_strpos && pt < Last_endpos) {if (PT-LAST_STRP OS <= last_endpos-pt) {cur_strpos = Pt;pressedarrow = R.id.start_pos;} else {cur_endpos = Pt;pressedarrow = R.id.end_ POS;}} else if (PT <= last_strpos) {cur_strpos = Pt;pressedarrow = R.id.start_pos;} else if (pt >= last_endpos) {Cur_endpos = Pt;pressedarrow = R.id.end_pos;} Requestlayout (); LOG.D (TAG, "down" + Cur_strpos + "" + cur_endpos); last_endpos = Cur_endpos;last_strpos = Cur_strpos;break;case MotionEve Nt. ACTION_MOVE:LOG.D (TAG, "MOVE" + Cur_strpos + "" + Cur_endpos); if (Pressedarrow = = R.id.start_pos) {if (pt < LAST_ENDP OS) Cur_strpos = pt;} else if (Pressedarrow = = R.id.end_pos) {if (pt > Last_strpos) cur_endpos = pt;} Requestlayout (); last_endpos = Cur_endpos;last_strpos = Cur_strpos;break;case MotionEvent.ACTION_UP:updateCalibrator (int) cur_strpos); break;} return false;}}
Such a look at this ontouchlistener should be no problem. A return of false at the end indicates that the event has been consumed here. But open Ddms to view the print log. When the finger is sliding to the imageview of the above touch listener, it is always printed action_move here, very obviously not at all. Later, all kinds of search problems can not be found. Because the Action_down is able to enter. But Action_move and action_up are not, it is not the problem of the code.
A variety of search only found that the settings to listen to the view of the properties set to Android:clickable= "true" so talented enough to respond to Action_move and action_up.
<imageview android:id= "@+id/track" android:layout_width= "match_parent" android:layout_height= " 20DP " android:clickable=" true " android:layout_gravity=" center " android:background=" #00000000 " Android:baselinealignbottom= "true" android:visibility= "visible"/>
It's down here. also provides a convenient for others
View in Android can only receive a method that Action_down cannot receive action_move and ACTION_UP resolution