Сообщение от Жека
Полагаю, ошибка в строке
setContentView(dynamicview);
^ ты ставишь в качестве контента свой лэйаут, а нужно ставить всю xml-льку лэйаута.
Вот так:
setContentView(R.layout.levels);
|
Кастомный вью тоже можно установить в content
Вот минимальный код который работает:
LinearLayout linearLayout = new LinearLayout(this);
linearLayout.setOrientation(LinearLayout.VERTICAL);
for (int i = 0; i < 10; ++i) {
Button button = new Button(this);
button.setText(String.format("Button %d", i));
linearLayout.addView(button, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
}
setContentView(linearLayout);