How to add/remove Fragment on Button click?
At present I have got a "RELATIVE_LAYOUT" container which I am using for adding my fragment. I am using OnClickListener on a button to load the fragment XML layout into the RelativeLayout container. What I want to achieve is that when I press the button once, the fragment should load...and when I press it again the fragment should be removed. I've already tried using integer to identify if fragment is loaded, but failed. Any help Appreciated... CODE: public class MainActivity extends Activity { Button B1,B2; int boolb1=0, boolb2=0; @Override protected void onCreate(Bundle savedInstanceState) {