I have one Activity in that there are no Buttons but I have coded it in such a way that another Activity comes, now in this second Activity there are three Buttons, on which when I click all inflating different respective activities.
In this second Activity there I have added one more Button, on clicking this 4th Button I don’t want another Activity to come in foreground instead i just want another layout to be inflated(I don’t wanna change the Activity)
In that layout(which i need to inflate) I have a ListView which has a list of certain sites, when this layout is inflated the list of sites should be shown and as i click on there sites its should take me to that webpage.
PROBLEM 1:
How to inflate just the xml on click of the 4th Button without changing the Activity.
PROBLEM 2:
When the xml is inflated and if I click on BackButton the Activity containing all the 4 Buttons should be displayed.
Here is the code that I’m using to inflate another xml:
fourthButton.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v) {
callingMore();
}
});
private void callingMore() {
LayoutInflater inflater = getLayoutInflater();
View layout = inflater.inflate(R.layout.web_site_list_xml, (ViewGroup)findViewById(R.id.site_list));
}
BUT this code gives a force close and no xml is being inflated and if I use setContentView( R.layout.web_site_list_xml) inside callingMore() method
the xml is inflated but that xml doesn’t show anything and then if I hit BackButton, the Activity that has all 4 Buttons isn’t shown.
I tried this code..hope helps to you..
1.layout_existed.xml
2.layout_toinfliate.xml
3.LayoutInflateDemo.java