進場 Animation 元件1=AnimationUtils.loadAnimation(this,android.R.anim.slide_in_left);
ImageSwitcher.setInAnimation(元件1);
退場 Animation 元件1=AnimationUtils.loadAnimation(this,android.R.anim.slide_out_right);
ImageSwitcher.setOutAnimation(元件1);
package com.example.theoryproject1;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.*;
public class Imageswitch1 extends Activity
{
private ImageSwitcher is1=null;
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.imageswitch1);
is1=(ImageSwitcher)findViewById(R.id.imageSwitcher1);
Animation in=AnimationUtils.loadAnimation(this,android.R.anim.slide_in_left);
Animation out=AnimationUtils.loadAnimation(this,android.R.anim.slide_out_right);
is1.setInAnimation(in);
is1.setOutAnimation(out);
Button bt1=(Button)findViewById(R.id.button1);
Button bt2=(Button)findViewById(R.id.button2);
bt1.setOnClickListener(mybtlistener3);
bt2.setOnClickListener(mybtlistener3);
}
Button.OnClickListener mybtlistener3 = new Button.OnClickListener()
{
@Override
public void onClick(View v)
{
switch (v.getId())
{
case R.id.button1:
{
is1.showPrevious();
break;
}
case R.id.button2:
{
is1.showNext();
break;
}
}
}
};
}
---------------------
沒有留言:
張貼留言