0

I'm trying for 2 weeks now to create a flipping layout in an android app, but nothing.. all the tutorials on the internet I've read, but nothing.. please, could someone, please, help me with this.. this is my Flippingactivity:

package com.ad;
import android.R;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.animation.Animation;
import android.view.animation.Animation.AnimationListener;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.app.Activity;
public class MainActivity extends Activity implements OnClickListener,
AnimationListener {

       private Animation animation1;
       private Animation animation2;
       private boolean isBackOfCardShowing = true;
       @Override
       protected void onCreate(Bundle savedInstanceState) {
             super.onCreate(savedInstanceState);
             setContentView(R.layout.activity_main);
             animation1 = AnimationUtils.loadAnimation(this, R.anim.to_middle);
             animation1.setAnimationListener(this);
             animation2 = AnimationUtils.loadAnimation(this, R.anim.from_middle);
             animation2.setAnimationListener(this);
             findViewById(R.id.button1).setOnClickListener(this);
       }
       @Override
       public void onClick(View v) {
              v.setEnabled(false);
              ((ImageView)findViewById(R.id.imageView1)).clearAnimation();
              ((ImageView)findViewById(R.id.imageView1)).setAnimation(animation1);
              ((ImageView)findViewById(R.id.imageView1)).startAnimation(animation1);
        }
        @Override
        public void onAnimationEnd(Animation animation) {
              if (animation==animation1) {
                     if (isBackOfCardShowing) {
        ((ImageView)findViewById(R.id.imageView1)).setImageResource(R.drawable.card_front2);
                       } else {
        ((ImageView)findViewById(R.id.imageView1)).setImageResource(R.drawable.card_back);
                       }
                       ((ImageView)findViewById(R.id.imageView1)).clearAnimation();
         ((ImageView)findViewById(R.id.imageView1)).setAnimation(animation2);
         ((ImageView)findViewById(R.id.imageView1)).startAnimation(animation2);
                 } else {
                        isBackOfCardShowing=!isBackOfCardShowing;
                        findViewById(R.id.button1).setEnabled(true);
                 }
        }
        @Override
        public void onAnimationRepeat(Animation animation) {
               // TODO Auto-generated method stub
        }
        @Override
        public void onAnimationStart(Animation animation) {
        // TODO Auto-generated method stub
        }
}

Ok. So the problems: 1. At the setContentView, if I put my activity_main, it says that it can not be resolved or it is no a field.. 2. They are not recognizing my anim folder where I was the transition.. I created the anim folder in /res, but they still not recognising my xmls files.. 3. At R.id.imageView1 they are not recognising my image id too..

I tried: clean the project.. nothing. Refresh the /res before making the xmls.. nothing. Importing .R in many different ways.. nothing.. nothing.. nothing. HELP !

So. I'am backing someone who knows what's happening to help me, I'am exhausted of trying, and trying but nothing. PLEASE, please, please, help me a little bit.Thanks, and I'll be grateful. Have a nice day !!!

user3104504
  • 81
  • 1
  • 1
  • 8

1 Answers1

0

You didn't post enough information to fully understand the problem you are having, but i'm guessing that this training article will help you.

Or Bar
  • 1,566
  • 11
  • 12
  • What do you want to know more? Tell me and i'll specify exactly what you want to know for helping me. I tried that tutorial too...but its not exactly what I want..This are my issues: 1. At the setContentView, if I put my activity_main, it says that it can not be resolved or it is no a field.. 2. They are not recognizing my anim folder where I was the transition.. I created the anim folder in /res, but they still not recognising my xmls files.. 3. At R.id.imageView1 they are not recognising my image id too.. – user3104504 Jan 26 '14 at 16:58