Sunday, April 21, 2013

[android help] How can I make buttons click at random

android - How can I make buttons click at random - Stack Overflow








Tell me more ×

Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

















I have a menu with x number of buttons that all go to different pages the problem is I have to start at the button at the top n go down I'm order for it work without crashing. If I click on the second or third button without going to the prior buttons I get a crash. I'm not sure if this is the emulator or is there some java code I can put that will allow me to click any button at random? Thanks.



package com.android.nameofmyappy;

import android.app.Activity;
import android.os.Bundle;
import android.content.Intent;
import android.view.View;
import android.widget.Button;


public class Mainmenu extends Activity {

/** Called when the activity is first created. */
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mainmenu);

Button Next = (Button) findViewById(R.id.bs);
Next.setOnClickListener(new View.OnClickListener() {
public void onClick(View view) {
Intent myIntent = new Intent(view.getContext(), Bs.class);
startActivityForResult(myIntent, 0);
};
});
}
}


that is a part of the code i have more buttons that have different id and lead to diff pages successfully if i start at the top button and work to the bottom but i would like to be able to click on any button at random...





























One way to perform UI fuzzy testing (randomly interacting with all UI element, such as buttons) is monkey runner, you can use adb:



adb shell monkey -p -v 500


This will randomly press anything 500 times to test against crashes.




















default







.

stackoverflow.comm

No comments:

Post a Comment

Google Voice on T-Mobile? [General]

Google Voice on T-Mobile? So I recently switched from a GNex on Verizon to a Moto X DE on T-Mobile. I had always used Google Voice for my v...