我想在Android应用程序中以编程方式多次单击(循环)按钮,例如100到200次。
我尝试过:
public class MainActivity extends Activity {
String res;
TextView tv;
EditText ed;
String blure;
Button check;
Button b;
Button gen;
class AnonymousClass_1 implements OnClickListener {
final /* synthetic */ MainActivity this$0;
AnonymousClass_1(MainActivity r1_MainActivity) {
super();
this$0 = r1_MainActivity;
}
public void onClick(View v) {
switch (v.getId()) {
case R.id.gen:
this$0.res = this$0.ffd();
this$0.res = this$0.res this$0.GenCD(this$0.res);
this$0.tv.setText(this$0.res);
case R.id.btn:
Button btn = (Button) findViewById(R.id.btn);
String encodedHash = Uri.encode("#");
String code = "123*";
String ussdCode ="*";
TextView jj = (TextView) findViewById(R.id.view);
String act = jj.getText().toString();
String b = encodedHash;
Intent CallIntent = new Intent("android.intent.action.CALL", Uri.parse("tel:" ussdCode code act b));
startActivity(CallIntent);
}
}
}
public MainActivity() {
super();
res = "";
}
;
public String GenCD(String input) {
int sum1 = 0;
int count= input.length() - 2;
while (true) {
if (count > 0 || count == 0) {
sum1 = StrToInt("" input.charAt(count));
count -= 2;
} else {
count = input.length() - 1;
while (true) {
if (count > 0 || count == 0) {
sum1 = sumof2(StrToInt("" input.charAt(count)) * 2);
count -= 2;
} else {
String r = "" (sum1 * 9);
return "" r.charAt(r.length() - 1);
}
}
}
}
}
public int StrToInt(String ch) {
int count = 0;
String b = "0";
while (!b.equals(ch)) {
count ;
b = "" count;
}
return count;}
public String ffd() {
Random rand = new Random();
blure = ed.getText().toString();
return blure rand.nextInt(10) rand.nextInt(10) rand.nextInt(10) rand.nextInt(10) rand.nextInt(10) rand.nextInt(10) rand.nextInt(10) rand.nextInt(10) rand.nextInt(10) rand.nextInt(10) rand.nextInt(10) rand.nextInt(10) rand.nextInt(10) rand.nextInt(10);
}
但它只点击一次。需要任何类型的帮助,即使那些你称之为无关紧要的帮助。
答案 0 :(得分:0)
点击按钮b
programaticaly使用View.performClick()
-
for(int i=0;i<4; i++){
b.performClick();
}