我需要在 30 个按钮上触发 30 次按钮点击,但应用程序崩溃可能是由于内存过度使用,我使用了对 enter 键侦听器中的每个按钮执行点击。有没有另一种方法可以触发按钮单击,也许有一个按钮可以同时触发 30 个按钮,这意味着只需要一个 performclick 功能。
请帮助我已经坚持了一年多。
editext.setOnKeyListener(new View.OnKeyListener() {
public boolean onKey (View v, int keyCode, KeyEvent event) {
// TODO Auto-generated method stub
if (keyCode==KeyEvent.KEYCODE_ENTER) {
if ("cat".equalsIgnoreCase(editext.getText().toString())) {
but1.performClick();
}
if ("dog".equalsIgnoreCase(editext.getText().toString())) {
but2.performClick();
}
if ("horse".equalsIgnoreCase(editext.getText().toString())) {
but3.performClick();
}
if ("pony".equalsIgnoreCase(editext.getText().toString())) {
but4.performClick();
}
if ("lion".equalsIgnoreCase(editext.getText().toString())) {
but5.performClick();
}
if ("monkey".equalsIgnoreCase(editext.getText().toString())) {
but6.performClick();
}
if ("goat".equalsIgnoreCase(editext.getText().toString())) {
but7.performClick();
}
if ("bear".equalsIgnoreCase(editext.getText().toString())) {
but8.performClick();
}
if ("mule".equalsIgnoreCase(editext.getText().toString())) {
but9.performClick();
}
if ("wolf".equalsIgnoreCase(editext.getText().toString())) {
but10.performClick();
}
if ("cow".equalsIgnoreCase(editext.getText().toString())) {
but11.performClick();
}
return true;
}
}
});
我明天会发布 logcat .. 谢谢大家的帮助