So, When I click on it it will go do the first animation which is sliding the right alittle bit and staying there and then it will AUTO do the second animation and slide back
This is how its SUPPOSED TO GO
You click on it and it will slide to the right. And when you click on it again it will slide BACK to the left.
My code:
public void sideBar()
{
ImageView sidebar = (ImageView)findViewById(R.id.sidebar);
if(out == 0)
{
mSlideInRight = AnimationUtils.loadAnimation(this, R.anim.slide_in_right);
mSlideInRight.setFillAfter(true);
sidebar.startAnimation(mSlideInRight);
out= 1;
}
if(out == 1)
{
mSlideInLeft = AnimationUtils.loadAnimation(this, R.anim.slide_in_left);
sidebar.startAnimation(mSlideInLeft);
out=0;
}
}
This part is where it handles when you click on it
public void onClick(View v) {
switch(v.getId())
{
case R.id.sidebar:
sideBar();
break;
}
}
Change your
condition to
In it’s current form, the code will execute the second block after finishing the first. After all, you just explicitly set
out = 1.