Array of Buttons in Android

后端 未结 6 1906
庸人自扰
庸人自扰 2020-12-29 12:34

I want to map the buttons to an array of buttons and the code has no errors while compiling but there is force close when i run it:

Button buttons[];

@Overr         


        
6条回答
  •  心在旅途
    2020-12-29 12:59

     Button buttons[] = null; 
    

    button has to be created, using the new operator:

     Button buttons[] = new Button[9];
    

提交回复
热议问题