how to remove a view

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


Sponsored Links
 Hi,

How to remove a view added by addContentView method?

Thanks,
Billsen

--~--~---------~--~----~------------~-------~--~----~



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.

Thanks,
Billsen





--~--~---------~--~----~------------~-------~--~----~



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.

 http://code.google.com/android/reference/android/view/View.html #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. Broadcast Receiver / Service will only restart my activity once.

I'm running into the same problem, "process is bad" error!  No way to
recover?




> 

2. Using java surface on the native side

I'm having issues when trying to use the java surface on the native
side. However, when I create the surface on the native side, the media
playback is fine.

The following are the things that I'm doing in my code:

1. Creating a Surface View and getting the Surface from the Surface
Holder from the application layer.
2. Using JNI, pass the Surface Holder object to your native
application.
3. Use this object to obtain Surface object

However, the sufracehandle is null in the JNI. Have anyone faced
similar issues ? Any workarounds or suggestions on how to fix this
issue?

My code would look like:

Player.java:
Class Player
{
Surface mSurface;
private SurfaceView surfaceView;
private SurfaceHolder surfaceHolder;
native void play ();

onCreate ()
{
surfaceView = (SurfaceView)
findViewById(R.id.SurfaceViewRendererSurface);
surfaceHolder = surfaceView.getHolder();
surfaceHolder.addCallback(this);
surfaceHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
/* Populate mSurface object here. */
mSurface = surfaceHolder.getSurface ();
......
play ();
......
}
}

Player.cpp:
.....
.....
struct fields_t {
jfieldID surface;
jfieldID surface_native;
};
static fields_t fields;

static sp<Surface> get_surface(JNIEnv* env, jobject thiz) {
Surface* const p = (Surface*)env->GetIntField(thiz,
fields.surface_native);
return sp<Surface>(p);
}

jint Java_com_test_Media_Media_play (JNIEnv *env, jobject thiz)
{
sp<Surface> nSurfaceHandle;
jobject surface = env->GetObjectField(thiz, fields.surface);

if (surface != NULL) {
const sp<Surface>& native_surface = get_surface(env, surface);
nSurfaceHandle = native_surface;

if (nSurfaceHandle == NULL)
{
LOGE ("ERROR :: Surface Handle NULL");
}
}
return 0;
}


Thanks in advance.

-- 

3. Is app's first run?

4. CAMERA permission features

5. email multi attachments

6. Multiple OpenGL Activities

7. msgid in strings.xml