// 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;
}
}
//////////////////////////////// Hi, I have a problem making menu bar.
It works similar as Facebook menu bar-
(when i press the button, menu appears that contains Expandable listview and main layout moves to right side of the page).
The problem is, when i click the listview to expand parent row(to see child row),
menu disappears and main layout get back to the main side.
I try to figure it out, when I force to expand parent row by using expandGroup() method,
it happens again.
I want to solve it but i can't by myself. plz help me~ (srry for my bad English)
-> I made it by using AnimationListener.