sherif
sherif

Reputation: 33

switching between views

I am trying to make my app view multiple views I made 2 xml files (main, sub) and I switch between them using :

setContentView(R.Layout.main);

setContentView(R.Layout.sub);

When I switch to the sub, it switches fine. However, When I switch back to main, the app crashes and I have no clue why it did that.

The only line that seems to make it crash is the calling of setContentView(R.Layout.main); for the second time. any clue on that ?

Upvotes: 1

Views: 1418

Answers (1)

Cristian
Cristian

Reputation: 200170

You should provide the logcat output so that we can know what the problem is. However, I'd recommend to use something like ViewFlipper instead of switching views using setContentView.

Upvotes: 4

Related Questions