android 自定义listener对象被自动析构和重建

来源:互联网 发布:网络舆情的最新发展 编辑:程序博客网 时间:2024/06/07 23:53
@Overridepublic boolean onTouchEvent(MotionEvent ev) {// TODO Auto-generated method stub    // only after long click this event can triger        //big bug in it , do it later             Log.v("movejudge", "enter onTouchEvent " + "ev.action "                    + ev.getAction() + " longPress: "                    + HorizontialListView.this.mLongClick + " actionMove:"                    + actionMove + " MoveSucess " + moveSucess);                      if (HorizontialListView.this.mLongClick == true)            {                int action = ev.getAction();                //move event ,after long click                if (action == MotionEvent.ACTION_MOVE && moveSucess == false)                {                    // do something;//                   Log.v("movejudge ","after"+ moveSucess+"");                                    moveSucess = myOnGestureListener.onMove(ev);                                                    actionMove = true;                    Log.v("movejudge "," in MoveEvent: moveSucess "+moveSucess+" actionMove "+ actionMove);                }                // action up :after actionMove and Move not sucess                else if (action == MotionEvent.ACTION_UP && actionMove == true)                { // if action up then the longclick =true                                                            Log.v("movejudge", "enter action up");                                        HorizontialListView.this.mLongClick = false;                                        if (moveSucess == true)                    {                        moveSucess = false;                    }                    else                    {                                               myOnGestureListener.onUp();                        HorizontialListView.this.mLongClick = false;                        actionMove = false;                        moveSucess = false;                    }                }            }return super.onTouchEvent(ev);}
自定义horizlist里面的元素被remove掉后难道关联到list的listener也被重构了?导致逻辑混乱,后来将内部类成员变量定义为外部内成员对象才解决问题。

原创粉丝点击