How to make relative layout GONE inside ViewFlipper on condition

I have an XML, in that XML i have a RelativeLayout say R1, now inside R1 i have one ViewFlipper and inside ViewFlipper i have 7 relative layouts, Everything works fine if i load all seven on my UI, but on condition i want only 3 relative layout (inside ViewFlipper) to be shown on the UI. Can anyone help me to make rest 4 relative layouts to be View.GONE.I tried setting them \[code\] if(X==Y){ findViewById(R.id.relativeA).setVisibility(View.GONE); findViewById(R.id.relativeB).setVisibility(View.GONE); findViewById(R.id.relativeC).setVisibility(View.GONE); findViewById(R.id.relativeD).setVisibility(View.GONE); }\[/code\]but this is not working. I set this in onCreate under the require condition, but this view gets GONE only when the activity is launched and when i Fling here and there with the finger, all layouts come on the UI.Now the only solution I am left is to create another XML with required relativelayouts, but the problem is my XML is quite heavy and i dont wanna use this last option. Kindly help
 
Back
Top