Ich benutze derzeit Android Studio für ein Dashboard zur Visualisierung von Live-Daten.Verstecken eines Cardview mit Kind Webview in Android Studio
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="190dp"
android:layout_marginBottom="5dp"
android:layout_marginTop="5dp"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<WebView
android:id="@+id/webviewCO2"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="CO2"
android:textAppearance="@style/TextAppearance.AppCompat.Title"
android:textColor="@color/background_floating_material_dark"
android:layout_marginTop="5dp"
android:layout_marginLeft="5dp" />
<TextView
android:id="@+id/CO2_ti"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="#000000"
android:text="-"
android:textSize="40dp"
android:textAlignment="center"
android:layout_marginTop="5dp" />
</LinearLayout>
</android.support.v7.widget.CardView>
Dies ist eine der Komponenten meines Dashboards. Einige Geräte haben jedoch keinen CO2-Sensor und ich möchte dies in der Ansicht komplett ausblenden, wenn das der Fall ist.
Wenn ich die Webansicht habe, gibt es eine Art Code, um das "Elternelement" wie in HTML zu bekommen, so dass ich die Sichtbarkeit der CardView auf GONE setzen kann?
Ich bin derzeit in der Lage, die Webansicht wie diese
WebView webViewCO2;
webViewCO2 = (WebView) view.findViewById(R.id.webviewCO2);
Gibt es somthing ähnlich ich die cardView bekommen cuold tun zu bekommen, so dass ich seine Sichtbarkeit ändern? (Vielleicht, wenn gab ich das cardView eine ID?)