This is the code I have built so far. The shake detector is complete and works, I just don't know what to write for the execution code at line 26. I have 10 images stored in my res/drawable-hdpi folder, entitle 1-10 and I want to change between them randomly when I shake it. I will eventually try and implement some transistions betwen images, so any advice on that would be amazing!
import java.util.Random;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
public class MainActivity extends Activity {
private ShakeDetector mShaker;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//Shake Detection
mShaker = new ShakeDetector(this);
mShaker.setOnShakeListener(new ShakeDetector.OnShakeListener () {
public void onShake()
{
//Code here is processed after shake.
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}