Android performClick on random button
I need to do performClick() method on random button. Getting NullPointerException
final Button[] buttons = {bt1, bt2, bt3, bt4, bt5, bt6, bt7, bt8, bt9};
bt1.setOnClickListener(new View.OnClickListener() {
public void onClick(View p1)
{
// TODO: Implement this method
int rando = (int) (Math.random()*9);
Button randombutton = (buttons[rando]);
randombutton.performClick();
}
});
Read more
stackoverflow.comm