Parent Activity's code getting executed, but the result (animation) is not showing up

跟風遠走 提交于 2019-12-02 08:27:55

Problem solved, just had to initialize the view once again in onOptionsItemSelected since the right layout has changed now. The method now looks like:

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
    case android.R.id.home:

    _rootLayout = (RelativeLayout) findViewById(R.id.rl_root);
    _leftLayout = (RelativeLayout) findViewById(R.id.ll_lhs_menu);
    _rightLayout = (RelativeLayout) findViewById(R.id.rl_right);

    _leftLayout.setVisibility(View.VISIBLE);
    int width = _leftLayout.getWidth();
    if (width == 0) {
        width = 300;
    }

if (!isMenuVisible()) {
    Toast.makeText(this, "Executed successfully...", Toast.LENGTH_LONG).show();
    _leftLayout.setVisibility(View.VISIBLE);

    _rightLayoutParams = new LayoutParams(
        _rightLayout.getWidth(), _rightLayout.getHeight());
    _rightLayoutParams.setMargins(width, 0, -width, 0);
    _rightLayout.setLayoutParams(_rightLayoutParams);

    Animation slideRight = setRightSlidingAnimation();
    _leftLayout.startAnimation(slideRight);
    _rightLayout.startAnimation(slideRight);
} else {
    Animation slideLeft = setLeftSlidingAnimation();
    _rightLayout.startAnimation(slideLeft);
    _leftLayout.startAnimation(slideLeft);
}

setMenuVisible(!isMenuVisible());
break;
}
return false;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!