This code is under the on click listener and also under the on create method, and time i click on the textView or loads the page it stops running and write Unfortunately, appName has stopped.
for (int i = 0 ; i < MAX_BUTTONS; i++){
Button button = (Button) getLayoutInflater().inflate(R.layout.button_layout,buttonsContainer,false);
button.setText("Test" + i);
button.setOnClickListener((View.OnClickListener) this);
buttonsContainer.addView(button);
if (i != MAX_BUTTONS - i){
buttonsContainer.addView(new Space(this),new ViewGroup.MarginLayoutParams(buttonsSpacing,buttonSize));
}
}