1

当我触摸所选图像时,我想要一个动画(例如:淡出)。我在这里使用轮播示例:Android 3D Carousel

我的代码是

public class MainActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);
    //Animation fadeout = AnimationUtils.loadAnimation(this, R.anim.fadeout);


    Carousel carousel = (Carousel)findViewById(R.id.carousel);
    carousel.setOnItemClickListener(new OnItemClickListener(){

        @Override
        public void onItemClick(CarouselAdapter<?> parent, View view,
                int position, long id) {                
            //Toast.makeText(MainActivity.this, "Position=" + position, Toast.LENGTH_SHORT).show();

            if(position==0){
                String toastMessage = String.format("RFID");
                Toast.makeText(getApplicationContext(), toastMessage, Toast.LENGTH_LONG).show();

                Animation anim = null;  
                anim = new RotateAnimation(0.0f,+360.0f);  
                anim.setInterpolator(new AccelerateDecelerateInterpolator());  
                anim.setDuration(30000);
                findViewById(R.id.carousel).startAnimation(anim);    

                Intent i = new Intent();
                i.setClass(MainActivity.this, web_rfid.class);
                startActivity(i);

            }

        }

    });
}

我希望旋转选定的图像,但结果是整个屏幕旋转。问题是

findViewById(R.id.carousel).startAnimation(anim);   

但我不知道如何在我的代码中找出选定的图像。请帮帮我。谢谢。

4

0 回答 0