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.view.Menu;

public class MainActivity extends Activity {

    private ShakeDetector mShaker;
    protected void onCreate(Bundle savedInstanceState) {

        //Shake Detection
         mShaker = new ShakeDetector(this);
            mShaker.setOnShakeListener(new ShakeDetector.OnShakeListener () {
              public void onShake()
                //Code here is processed after shake.  


    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(, menu);
        return true;


Recommended Answers

All 3 Replies

You better to be more specific as where is the issue, what you have problem to work with. Nobody will write code for you just because you posted auto-generated code stub


Well since it is LOL to you we can close this thread

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.