Much depends on what you want to do and how you want to do it.
But, honestly speaking, these are so basic things that I suggest you to follow some beginner tutorials to familiarize yourself with those basic concepts.
There is not much to show code, you just have to do that to a certain condition (only you can know and decide) the corresponding action will go to the next level layout.
ok thanks