制作菜单栏时出现ExpandableListView问题(与facebook类似)

时间:2013-02-25 09:08:50

标签: listview expandable

// class that defines events on clicking menu button
class NaviClickListener implements OnClickListener {
    @Override
    public void onClick(View v) {
        MainFrame me = MainFrame.this;
        Context context = me;
        Animation anim;


        if(isMenuOpened){
            Log.d("On NAVICLICKLISTENER CALLED", "true");
        }else{
            Log.d("On NAVICLICKLISTENER CALLED", "false");
        }

        int w = parentLinearLayout.getMeasuredWidth();
        int h = parentLinearLayout.getMeasuredHeight();
        int left = (int) (parentLinearLayout.getMeasuredWidth() * 0.55);

        if (!isMenuOpened) {
            // anim = AnimationUtils.loadAnimation(context, R.anim.push_right_out_80);
            anim = new TranslateAnimation(0, left, 0, 0);
            mainNaviLayout.setVisibility(View.VISIBLE);
            animParams.init(left, 0, left + w, h);


        } else {
            // anim = AnimationUtils.loadAnimation(context, R.anim.push_left_in_80);
            anim = new TranslateAnimation(0, -left, 0, 0);
            animParams.init(0, 0, w, h);
        }
        anim.setDuration(400);
        anim.setAnimationListener(me);
        //Tell the animation to stay as it ended (we are going to set the app.layout 
     first than remove this property)
        anim.setFillAfter(false);


        // Only use fillEnabled and fillAfter if we don't call layout ourselves.
        // We need to do the layout ourselves and not use fillEnabled and fillAfter 
  because when the anim is finished
        // although the View appears to have moved, it is actually just a drawing effect and the View hasn't moved.
        // Therefore clicking on the screen where the button appears does not work, but clicking where the View *was* does
        // work.
        // anim.setFillEnabled(true);
        // anim.setFillAfter(true);

        parentLinearLayout.startAnimation(anim);
    }
    }
  ///////////////

//about animation methods
 void layoutApp(boolean menuOut) {
        parentLinearLayout.layout(animParams.left, animParams.top,     
    animParams.right, animParams.bottom);
        //Now that we've set the app.layout property we can clear the animation, 
   flicker avoided :)
        parentLinearLayout.clearAnimation();

  }
@Override
public void onAnimationEnd(Animation animation) {
    // TODO Auto-generated method stub
    Log.d("On ANIMATIONEND CALLED", "ASDFASDFASDF");
    isMenuOpened = !isMenuOpened;
    if (!isMenuOpened) {
        mainNaviLayout.setVisibility(View.INVISIBLE);
    }
    layoutApp(isMenuOpened);
}
@Override
public void onAnimationRepeat(Animation animation) {
    Log.d("On ANIMATION repeat CALLED", "ASDFASDFASDF");
    // TODO Auto-generated method stub

}
@Override
public void onAnimationStart(Animation animation) {
    // TODO Auto-generated method stub

    Log.d("On ANIMATION start CALLED", "ASDFASDFASDF");
}
static class AnimParams {
    int left, right, top, bottom;

    void init(int left, int top, int right, int bottom) {
        this.left = left;
        this.top = top;
        this.right = right;
        this.bottom = bottom;
      }
  }

//////////////////////////////// 嗨,我在制作菜单栏时遇到问题。

它的工作方式与Facebook菜单栏类似 -

(当我按下按钮时,会出现包含可扩展列表视图和主布局移动的菜单 到页面的右侧)。

问题是,当我点击列表视图以展开父行(以查看子行)时,

菜单消失,主要布局返回主页。

当我通过使用expandGroup()方法

强制扩展父行时,我试图找出它

它再次发生。

我想解决它,但我不能自己解决。请帮助我〜(为我糟糕的英语而烦恼)

- >我是使用AnimationListener制作的。

0 个答案:

没有答案