Bonjour,
Je crée une petite application de présentation et j'utilise des Fragments pour slider d'une vue à l'autre. J'ai pensé, comme je veux appliquer des animations différentes sur chaques vue créer une sous-classe d'Activity ou à l'aide d'un switch case je définit l'application à appliquer et la termine. Ensuite je l'instancie dans le Fragment et appele la méthode qui applique l'animation.
Merci de votre indulgence, je débute sous android!

Extraits du code :

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
public class SimpleAnimation extends Activity {
 
	private AnimationListener listener;
 
	public void startAnimation(int id_view) {
 
		switch (id_view) {
		case 0: {
 
			ImageView anim_view = (ImageView) findViewById(R.id.image_view_asphalt_01);
			Animation fader = AnimationUtils.loadAnimation(this, R.anim.fade);
			anim_view.startAnimation(fader);
			fader.setAnimationListener(listener);
			if (fader.hasEnded()) {
				fader.cancel();
			}
			break;
		}
//		case 1: {
//			ImageView anim_view_02 = (ImageView) findViewById(R.id.image_view_asphalt_02);
//			ImageView animation = (ImageView) findViewById(R.id.image_view_anim__inox); 																					
//			animation.setBackgroundResource(R.drawable.animation_inox); 
//			AnimationDrawable animate = (AnimationDrawable) animation
//					.getBackground();
//			animate.start();
//		}
		}
	}
}
 
 
public class Fragment00 extends Fragment {
 
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
 
		SimpleAnimation animation = new SimpleAnimation();
		animation.startAnimation(0);
 
		if (container == null) {
 
			return null;
		}
		return (LinearLayout) inflater.inflate(R.layout.lay_asphalt_01,
				container, false);
	}
 
}


merci d'avance...