I want to have a sliding menu throughout my application which will be accessible for every activity in my application. For this, I created a parent activity to which all other a
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;
}