user2857609
user2857609

Reputation: 11

Call Buttons Automatically

i want to call 3 buttons simultaneously or using delay time.

how to call the buttons automatically with certain time like above?

Upvotes: 0

Views: 105

Answers (2)

user2511414
user2511414

Reputation:

Something like this?!

public boolean onOptionsItemSelected(MenuItem item) {
        Log.i(TAG, "Menu Item selected " + item);
        if (item == button1) {
            variabel.setViewMode(ClassOne.Object1);
    new Thread(new Runnable(){
    public void run(){try{Thread.sleep(5000);onOptionsItemSelected(button3);}catch(Exception ex){}}
    }).start();
        } else if (item == button2) {
            variabel.setViewMode(ClassOne.Object2);
        } else if (item == button3) {
            variabel.setViewMode(ClassOne.Object3);
            new Thread(new Runnable(){
    public void run(){try{Thread.sleep(5000);onOptionsItemSelected(button2);}catch(Exception ex){}}
    }).start();
        }

try to move this all in new thread so that ui thread continue to execute.

Upvotes: 1

Pankaj Sharma
Pankaj Sharma

Reputation: 1853

just call their listeners OnClick method using Thread.sleep(). and do not forget to separate this in new thread so that ui thread continue to execute use Handler for this.

Upvotes: 0

Related Questions