80,351
社区成员
发帖
与我相关
我的任务
分享
<LinearLayout android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_weight="1">
<FrameLayout android:id="@+id/webViewLayout"
android:layout_width="fill_parent" android:layout_height="fill_parent"></FrameLayout>
</LinearLayout>
FrameLayout webViewLayout = (FrameLayout) this.findViewById(R.id.webViewLayout);
WebView webView = new WebView(this);
webViewLayout.addView(webView);
webViewLayout.removeView(webView)
,但是执行了该方法后,webView依旧显示在屏幕上,被这个问题困扰了一下午,哪位高手指教指教???public class AndroidTest extends Activity {
FrameLayout webViewLayout;
WebView webView;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
webViewLayout = (FrameLayout) this.findViewById(R.id.webViewLayout);
webView = new WebView(this);
webViewLayout.addView(webView);
Button btnRemove = (Button)findViewById(R.id.btnRemove);
btnRemove.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
// TODO Auto-generated method stub
webViewLayout.removeView(webView);
}
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_weight="1">
<FrameLayout android:id="@+id/webViewLayout"
android:layout_width="fill_parent"
android:layout_height="200dip">
</FrameLayout>
<Button android:id="@+id/btnRemove"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Remove"/>
</LinearLayout>
rootLayout.startLayoutAnimation();
webViewLayout.requestLayout();
rootLayout.updateViewLayout(rootLayout, rootLayout.getLayoutParams());
三个方法都试过了,都没有刷新效果啊,还有其他的方法吗