This block of code does not work for me. I debugged and I think the error is coming from the setlayoutparams but it doesn't make sense because if I take out the for loop and create just 1 button (not an array of buttons) then it'll work.
Button btn[] = new Button[oNumber];
for (int i=0;i<oNumber;i++){
btn[i].setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
btn[i].setText(oName[i]);
System.out.println("making b's");
layout.addView(btn[i]);
}
This is the error I get. I do have the activity correctly written in the manifest.
08-14 12:45:56.482: E/AndroidRuntime(4060): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.rcontrol/com.example.rcontrol.ViewTarget}: java.lang.NullPointerException