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;
    }

}

Recommended Answers

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

Jump to Post

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

lol

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 1.20 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.