Panos
Panos

Reputation: 7407

Android (2.1+) load different layout for activity according to attributes sent from previous activity

I want to have an android activity that in general will recursively call the same activity until I set an attribute "status = something"... So I want when the activity starts , to have a different layout (enable couple of buttons that I don't want to be visible from the start of the application). Is it possible to load differrent layout.xml? Or will this be done only by java code?

Upvotes: 1

Views: 146

Answers (3)

AJcodez
AJcodez

Reputation: 34156

Calling a lot of activities over and over is probably a bad thing. Why not add buttons to a layout programatically (using java) when you are ready to have the buttons?

Make a layout where you will put them and give it an android:id, find that layout by id (findViewById()) and then add buttons to it- layout.addView(new Button());

Add the buttons when you set the attribute, in the same action so it will happen at the same time.

Upvotes: 0

Rajdeep Dua
Rajdeep Dua

Reputation: 11230

Doing it in Java is a better option. Though you could do a different setContentView() depending on the value of the status variable

Upvotes: 0

CChi
CChi

Reputation: 3134

Why don't you make those button invisible until "status = something"

Upvotes: 1

Related Questions