Force Main-Layout to Inflate

166 views Asked by At

I'll try another shot. Hopefully now i get the answere i totally Need.

Just imagine: I have a widget which calls(after onClick) a blank activity with no hardcoded code, just a Relative Layout with some views.(Layout provided by XML-layout-file).

My Activity:

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.myLayout);

When i add a for-loop to the onCreate-Method which adds 50 Buttons(take no care about layoutparams, orientation and so on). Just 50 simply Buttons

Like:

protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.myLayout);
for(int i = 0; i<50; i++) {
Button btn = new Button(this);
myLayout.add(btn);
}

I recognize that he only Shows the activity on the Screen until he finished to add all the Buttons.

My Question is: How can i prevent this!? How can i Show up the Activity with the Content from the XML-layout file and then(ONLY then) add one Button after another to the Layout.

Is this possible? If so, do i neew to redraw the whole activity and so on. Please give me advise to my issue.

0

There are 0 answers