1

"java.lang.IllegalStateException: The specified child already has a parent. You must call removeView() on the child's parent first android"以下のコードでエラーが発生します。

ログから、エラーが行に見られることがわかります。APIsetContentView(mWebPageParentView)で 。public void onHideCustomView()

これをできるだけ早く解決するのを手伝ってください。

//初期宣言。

private WebChromeClient mWebChromeClient = null;
private View mFullScreenVideoView;
private RelativeLayout mWebPageParentView;
private FrameLayout mFullScreenViewContainer = null;
private WebChromeClient.CustomViewCallback mFullScreenVideoViewCallback;

// コード

@Override
public void onShowCustomView(View view, CustomViewCallback  callback) {     

if (mFullScreenVideoView != null) {
callback.onCustomViewHidden();
return;
}

// The below line was missing while writing here. 
mWebPageParentView = (RelativeLayout) findViewById(R.id.lyt_main);
// The above line was missing while writing here. 
mWebPageParentView.setVisibility(View.GONE);                        
mFullScreenViewContainer = new FrameLayout(BrowserActivity.this);
mFullScreenViewContainer.setLayoutParams(LayoutParameters);
view.setLayoutParams(LayoutParameters);
mFullScreenViewContainer.addView(view);
mFullScreenVideoView = view;
mFullScreenVideoViewCallback = callback;
mFullScreenViewContainer.setVisibility(View.VISIBLE);
setContentView(mFullScreenViewContainer);
}

@Override
public void onHideCustomView() {
 if (mFullScreenVideoView == null) {
return;
  } else {
   // Hide the custom view.  
mFullScreenVideoView.setVisibility(View.GONE);
    mFullScreenViewContainer.removeView(mFullScreenVideoView);
mFullScreenViewContainer.setVisibility(View.GONE);

mFullScreenViewContainer = null;
mFullScreenVideoViewCallback.onCustomViewHidden();
// Show the content view.  
    mWebPageParentView.setVisibility(View.VISIBLE);
    setContentView(mWebPageParentView);
    }
 }
4

1 に答える 1