2017-06-29 11 views
0

現在、ライブデータを視覚化するためにダッシュボード用のAndroidスタジオを使用しています。Androidスタジオの子Webviewを使用してカードビューを非表示にする

<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> 

これはマイダッシュボードのコンポーネントの1つです。しかし、デバイスの中にはCO2センサーがないものがあり、そのような場合には、これを完全に非表示にしたいと考えています。
私はwebviewを持っているとき、「親要素」をHTMLのように取得するためのコードがありますので、CardViewの可視性をGONEに設定できますか?
私はその可視性を変更することができるようにcardViewを得るために行うcuold同様の気にいらがあります。この

WebView webViewCO2; 
webViewCO2 = (WebView) view.findViewById(R.id.webviewCO2); 

などのWebViewのを取得することができ、現在のですか? (たぶん場合、私はcardViewにIDを与えた?)

答えて

0
CardView cardView = (CardView) view.findViewById(R.id.cv_id); 

cardView.setVisibility(View.GONE) 

トリックをしたの

関連する問題