Android 尝试设置页面控件时如何调用removeView()?

Android 尝试设置页面控件时如何调用removeView()?,android,swipeview,pagecontrol,Android,Swipeview,Pagecontrol,我试图在swipeview中设置一些图像,并在该视图中添加一个页面控件,如下所示: //In onCreate swipeView = (SwipeView) findViewById(R.id.swipe_view); swipeView.setOnClickListener(this); pageControl = (PageControl) findViewById(R.id.page_control); pageC

我试图在swipeview中设置一些图像,并在该视图中添加一个页面控件,如下所示:

//In onCreate
swipeView = (SwipeView) findViewById(R.id.swipe_view);
            swipeView.setOnClickListener(this);
            pageControl = (PageControl) findViewById(R.id.page_control); 
            pageControl.setEnabled(true);
  setPagination();

private void setPagination() {
            for (int i = 0; i < lnoitem.lnoImageList.size(); i++) 
            {
                FrameLayout frame = new FrameLayout(MyAffairDetails.this);
                View child = MyAffairDetails.this.getLayoutInflater().inflate(R.layout.swipe_view_affair, null);
                frame.addView(child);

                final ImageView imgThumb      = (ImageView) child.findViewById(R.id.imgThumb);
                final WebView webViewThumb    = (WebView) child.findViewById(R.id.WebView);

                webViewThumb.getSettings().setLoadWithOverviewMode(true);
                webViewThumb.getSettings().setUseWideViewPort(false);
                webViewThumb.getSettings().setBuiltInZoomControls(false);
                webViewThumb.setVerticalScrollBarEnabled(false);
                webViewThumb.setScrollbarFadingEnabled(false);
                webViewThumb.setScrollContainer(false); 
                webViewThumb.setFocusable(false);
                webViewThumb.setClickable(false);
                webViewThumb.setBackgroundColor(Color.parseColor("#00000000"));

                String path = "";
                String name = lnoitem.lnoImageList.get(i).getBigImage();
                String html = "<body style='margin:0;padding:0;' ><img src='"+name+"' width='100%' height='100%' /></body>";
                webViewThumb.loadDataWithBaseURL(path, html, "text/html", "utf-8", "");

                webViewThumb.setWebViewClient(new WebViewClient() 
                {

                   @Override
                   public boolean shouldOverrideUrlLoading(WebView view, String urlNewString) {
                       return true;
                   }

                   public void onPageStarted(WebView view, String url) { }

                   @Override
                   public void onPageFinished(WebView view, String url) {
                       imgThumb.setVisibility(View.GONE);
                       webViewThumb.setVisibility(View.VISIBLE);
                   }                  
                });

               swipeView.addView(frame);        

            }
            swipeView.setPageControl(pageControl);
        }
}
xml:


有人能告诉我如何调用removeview()或如何在上述给定代码中避免此异常吗

swipeView.setPageControl(pageControl); 
正在将swipeView设置为pageControl的父级。 在设置此项之前,请尝试这样做以确保

pageControl.getParent();
也许您不应该在活动布局中包含pageControl。 而是这个

pageControl = (PageControl) findViewById(R.id.page_control);
这样做

pageControl = new PageControl(this);

swipeView.setPageControl(pageControl);

应该可以工作。

显示System.out.println(pageControl.getParent().getClass())的输出;和System.out.println(pageControl.getParent().equals(swipeView));我已经添加了xml,响应分别给出了类android.widget.RelativeLayout和false。请看一看,让我知道可能的解决方案。
pageControl = new PageControl(this);
swipeView.setPageControl(pageControl);