I am relatively new to android, i need to open a new screen when a button is clicked.
As i checked the posts here they suggest using setContentView() or using an Intent.
In case 2 a new the screen is opened as a new Activity, as i dont want this to happen
could u tell me if i can use LayoutInflater to open a new screen, if so how to do this.
I am relatively new to android, i need to open a new screen when
Share
your question suggests that, there is no need to use LayoutInflater. Check this code:
Here is all you need I think. But just in case I’m also posting XML files:
basic_layout_1.xml code
and basic_layout_2.xml code
//EDIT
What is important, this method of creating a new screen will cause that back button won’t display basic_layout_1 but it’ll exit your app (in example above). If you’d like to display previous screen you should override back button action (but in that case, why not use Intent?)