有两个Button,一个控制另一个Button移动,可是当Button移动以后,这个Button的事件监听无法触发,各位大神帮帮忙!

解决方案 »

  1.   

    这是获得动画的函数:
    public Animation getAnimation(float fromX, final int toX, float fromY,
    final int toY, int time) {
    TranslateAnimation translateAnimation = new TranslateAnimation(fromX,
    toX, fromY, toY);

    translateAnimation.setDuration(time);
    translateAnimation.setFillAfter(true);
    return translateAnimation;
    }
    这是给Button设置动画的函数:
    public void initAnimation() {
    if (mFlag) {
    mButtonRefresh.startAnimation(mMySQLiteLogic.getAnimation(0f, -mWidth / 2 + mButtonRefresh.getWidth() / 2, 0f, 0, 1000));
    mButtonSearch.startAnimation(mMySQLiteLogic.getAnimation(0f, mWidth / 2
    - mButtonSearch.getWidth() / 2, 0f, 0, 1000));
    mButtonAdd.startAnimation(mMySQLiteLogic.getAnimation(0f, 0, 0f,
    -(mWidth / 2 - mButtonAdd.getWidth() / 2), 1000));
    mFlag = false;
    }  else {
    mButtonRefresh.startAnimation(mMySQLiteLogic.getAnimation(-mWidth / 2
    + mButtonRefresh.getWidth() / 2, 0, 0f, 0, 1000));
    mButtonSearch.startAnimation(mMySQLiteLogic.getAnimation(mWidth / 2
    - mButtonSearch.getWidth() / 2, 0, 0f, 0, 1000));
    mButtonAdd.startAnimation(mMySQLiteLogic.getAnimation(0f, 0, -(mWidth / 2 - mButtonAdd.getWidth() / 2),
    0, 1000));
    mFlag = true;
    }
    }
    点击这个按钮播放动画:
    findViewById(R.id.button1).setOnClickListener(new OnClickListener() { @Override
    public void onClick(View v) {
    Log.d("Button1", "lllllllllllllllllllll");
    initAnimation();
    }
    });
    帮我看看怎么解决,谢了!
      

  2.   

    分别说明一下哪个是Button A,哪个是Button B,现在是A不能监听还是B不能监听?
      

  3.   

    mButtonAdd,mButtonSearch,mButtonRefresh这三个Button不能监听,当点击这个findViewById(R.id.button1) Button时,那三个Button开始移动,移动完后,再点击上面三个Button时,三个Button的监听事件没有被触发
      

  4.   

    View.OnClickListener l = new View.OnClickListener() { @Override
     public void onClick(View v) {
     switch (v.getId()) {
     case 1000:
     Log.d("mButtonAdd", "mButtonAdd");
     mMySQLiteLogic.startActivity();
     break;
     case 2000:
     mMySQLiteLogic.searchDialog(v);
     break;
     case 3000:
     Log.d("mButtonRefresh", "mButtonRefresh");
     mMySQLiteLogic.updataAdapter();
     break; case else: Log.d("other", "id = " + v.getId()); break;
     }
     }
     };
     mButtonAdd.setOnClickListener(l); mButtonAdd.setId(1000);
     mButtonSearch.setOnClickListener(l); mButtonSearch.setId(2000);
     mButtonRefresh.setOnClickListener(l); mButtonRefresh.setId(3000);