android - Assign Text of 2d array of buttons -


I have buttons on Android that I declare like this button grid [] [] = new button [3 ] [3];

Then I find the grid set [0] [0] = (button) VVIBID (RID. Middle Couple) which exists

When I try to change the text again I

the calling grid [0] [0] by .setText ("U");

I know the accident that I do not have this announcement or array setting because it only crashes when I go into the function which I am using to set text.

If the button .setText () is throwing a NullPointerException, then the button will be placed in your layout (R.D. Middle Couple) Your content should not currently be inflated / present in view.

Since the button grid [] [] = new button [3] [3]; In fact, you do not make the buttons you use, when you try to set the text, it will throw the NPE (because your searchviobiIID method is returning to zero when trying to set one up goes).

Before you reach these, the button must actually be instructed.

Example.

  button grid [] [] = new button [3] [3]; For (int i = 0; i & lt; grid.length; i ++) {for (int j = 0; j & lt; grid [i]. Length; j ++) {grid [i] ] = New button (reference); Parent.addView (grid [i] [ja]); }}  

Unless you manually set up buttons using findViewById () for each, but it is too much extra to keep references for buttons in multi-dimensional array Looks like work.


Comments

Popular posts from this blog

import - Python ImportError: No module named wmi -

Editing Python Class in Shell and SQLAlchemy -

c# - MySQL Parameterized Select Query joining tables issue -