代码改变世界

谁(何时)需要设置监听器(回调)

2015-04-15 09:53 by 徐亮, 148 阅读, 0 推荐, 收藏, 编辑
摘要:被东方向主动方发送数据需要利用回调。比如客户端是主动方,服务器是被动方。比如android中的activity是主动方,按钮是被动方。何时需要在回调方法中设置参数,比如android中的listView是被动方,当被动方listView被点击时,listView需要告诉activty1.我被点击了2... 阅读全文

事件的传播顺序

2015-03-19 09:39 by 徐亮, 189 阅读, 0 推荐, 收藏, 编辑
摘要:public class MyButton extends Button{ public MyButton(Context context , AttributeSet set) { super(context , set); } @Override public boolean onKeyDow... 阅读全文

理解GestureDetector

2015-03-18 10:24 by 徐亮, 144 阅读, 0 推荐, 收藏, 编辑
摘要:先来一个手势监听器public interface OnGestureListener { boolean onDown(MotionEvent e);}创建一个activitypublic class MainActivity extends Activity { GestureDetecto... 阅读全文

手势检测的回调方法中onfling与onscroll的区别

2015-03-17 17:28 by 徐亮, 702 阅读, 0 推荐, 收藏, 编辑
摘要:onfling参数:e1 The first down motion event that started the fling.e2 The move motion event that triggered the current onFling.velocityX The velocity of ... 阅读全文