how to remove a view

by Billsen » Thu, 11 Sep 2008 12:59:30 GMT

Sponsored Links

How to remove a view added by addContentView method?



how to remove a view

by hackbod » Thu, 11 Sep 2008 14:49:58 GMT

 setContentView() replaces any existing views.  If you want finer-
grained control, you can setContentView() a top-level layout manager,
which you can then add and remove views in as you desire.


Sponsored Links

how to remove a view

by Billsen » Sat, 13 Sep 2008 02:23:06 GMT

 Would you please provide a little more information?  I loaded
R.layout.main by setContentView(), then added a view with
addContentView. I need to remove the view added by addContentView by
clicking a button.



how to remove a view

by Kavi » Sat, 13 Sep 2008 03:12:25 GMT

 Look at the setVisibility method to change the visibility options for
the view. #setVisibility(int)

how to remove a view

by Billsen » Sat, 13 Sep 2008 04:56:39 GMT

 Thanks for your help. It works with setVisibility.


Re: how to remove a view

by Guilo » Fri, 20 May 2011 04:29:40 GMT

 I know it is old but I have the same problem. I want next to change the view 
added by addContentView. Indeed recalling addContenView throws an Exception 

05-19 22:28:31.785: ERROR/AndroidRuntime(11210): 
java.lang.IllegalStateException: The specified child already has a parent. 
You must call removeView() on the child's parent first.


Other Threads

1. Send key event using native methods or low level classes -- possible solutions ??

Hi Houcen,

take a look at the code of android-x86 that implaments a way to use MENU,
BACK and HOME buttons in a device with just touchscreen. The name of the
file that implements this is

The inconvenient is that you need to do this modification in the Android
plataform, but as you will use Android to a specific device, if think it is
not a big deal.



2010/2/24 Houcem Berrayana <>


2. services x threads


I'm trying to understand the idea behind the Services.

If it runs in the program's thread, why not create just a separate
thread (or AsyncTask) to do the job?

Can a service keep running in the background? For example, i want to
create a task that will continuously be polling data from a server,
even if the main application is not running. Can this be achieved with
a Service?




3. How to download an xml file from url in android

4. Download selalu Fetching

5. square layout in xml

6. Using ContentResolver to add a contact in the mobile

7. Tanya Instal SDK Pluggin