ANDRIOD事件响应--

来源:互联网 发布:java 的io重要吗 编辑:程序博客网 时间:2024/06/05 01:07
1.滑动/触摸事件响应
Button.OnTouchListenter(New OntouchListener)(){
@override
public boolean OnTouch(View v,MotionEvent event) {
int actionType=event.getAction;
if(actionType==MotionEvent.ACTION_DOWN){
sout(1);
}else{
sout(2);
}
}
//元事件 action_down /up /move
}
2.焦点事件(改变)
Button.OnFocusListenter(New OnFocusListenter)(){
@override
public boolean OnFocusChange(View v,boolean event) {
sout(3);
}
//元事件 action_down /up /move
}
3.长按事件
Button.OnLongClickListenter(New OnLongClickListenter)(){
@override
public boolean OnLongClick(View v) {
sout(3);
return true;//flase。如为true则消耗掉该事件,不下传。
}
}
4.键盘事件
Button.OnKeyListenter(New OnKeyListenter)(){
@override
public boolean OnKey(View v,int keyCode,KeyEvent event) {
sout(3);
return true;//flase。如为true则消耗掉该事件,不下传。
}
}
原创粉丝点击