• Advertisement
Sign in to follow this  

Animation - shakingProblem

This topic is 2220 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

hey guys.
following problem:

I want to let my startbutton shake if it is not touched within 10 seconds. this lecture is out of a book i baught for starting with Android programing. But although i am thinking of havin done everything correct, the button does not shake.

buttonID = button1

res/anim/wackeln.xml

<?xml version="1.0" encoding="utf-8"?>
<alpha xmlns:android="http://schemas.android.com/apk/res/android"
android:fromDegrees="-40"
android:toDegrees="40"
android:duration="1000"
android:repeatCount="20" />



and in my main activity:


private Animation animationWackeln;
private Button startButton;
private Handler handler = new Handler();


public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
Button button = (Button) findViewById(R.id.button1);
button.setOnClickListener(this);
animationWackeln = AnimationUtils.loadAnimation(this, R.anim.wackeln);
startButton = (Button)findViewById(R.id.button1);
}


private class WackleButton implements Runnable {

public void run() {
startButton.startAnimation(animationWackeln);
}
}

@Override

protected void onResume(){
super.onResume();
handler.postDelayed(new WackleButton(), 1000*10);
}


i hope someone will help. thank you

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement