Я хочу, чтобы мой просмотр изображений вращался под случайным углом с помощью Onclick(). Но почему Onlick() работает, а Imageview не может вращаться? Вот мой код.
ImageView rotate_plate;
Button debug_button;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
debug_button=(Button) findViewById(R.id.test_button);
debug_button.setOnClickListener(btngoOnClick);
}
private OnClickListener btngoOnClick = new OnClickListener() {
public void onClick(View v) {
debug_button.setText("Click");
rotate_plate=(ImageView) findViewById(R.id.wheel);
int stopturnnum = (int)(Math.random() *360);
Animation am = new RotateAnimation(0, stopturnnum, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
am.setDuration( 3000 );
am.setRepeatCount(1);
am.setFillAfter(true);
rotate_plate.setAnimation(am);
am.startNow();
}
};