在我的应用程序的主页中,服务器向我发送了一些标志。其中一个是广告标志。如果它设置为true,我需要显示广告,如果它设置为false,我不应该显示它。Android,如何从UI中删除视图?
现在,这个问题。我需要像这样在XML文件中放置广告空间。
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<RileativeLayout
android:id="@+id/adv"
android:layout_width="fill_parent"
android:layout_height="100dip">
</RileativeLayout>
.
.
.
</LinearLayout >
根据上面的代码,如果该标志被设置为false,我没有表现做广告,但差距仍然留在我的屏幕上。如何动态地从我的代码中删除它,并将其他视图(这是它的影响)向上移动?
view.setVisibility(View.GONE) –
这将做的工作'findViewById(R.id.adv).setVisibility(View.GONE);' –