2016-09-07 3 views
0

これは私のメインの活動では、私のactivity_main.xmlどのようにフラグメント内activity_main.xmlのリニアレイアウトにアクセスするには

<?xml version="1.0" encoding="utf-8"?> 
    <RelativeLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent"> 

    <LinearLayout 
     android:id="@+id/banner_layout" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@color/contact_card_line_color" 
     android:gravity="center_horizontal" 
     android:orientation="vertical"> 

     <TextView 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="@string/no_internet_connection" 
      android:textColor="@color/contact_card_initial_color" 
      android:textSize="@dimen/banner_text_size" /> 
    </LinearLayout> 

    <FrameLayout 
     android:id="@+id/fragment_holder" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:layout_below="@+id/banner_layout"> 

    </FrameLayout> 


    </RelativeLayout> 

ですが、私は、私のフラグメントで

setContentView(R.layout.activity_launch_view); 

    fragment.setArguments(getIntent().getExtras()); 
      getFragmentManager().beginTransaction().replace(R.id.fragment_holder, fragment).commit(); 

を行う

1)デフォルトでインターネットに接続されていないテキストが表示されませんでした。 2)私はそれらにアクセスできますが、ランタイムエラーはありません。

+0

背後にある理由はでframeLayoutがtextView.Toはフレームレイアウトの後に、この問題の場所のTextViewを解決隠すように、あなたがでframeLayout前のTextViewを置いています。 – Vishwa

+0

フラグメントからの線形レイアウト用のイベント用インターフェイスを使用する –

答えて

0

これは相対的なレイアウトなので、マッチする親framelayoutはテキストビューと重なっているので、linearlayoutに変更するか、layout_belowタグをバナーレイアウトに使用する必要があります。

0

使用このコード

<?xml version="1.0" encoding="utf-8"?> 
     <LinearLayout 
     xmlns:android="http://schemas.android.com/apk/res/android" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:orientation="vertical"> 

     <LinearLayout 
      android:id="@+id/banner_layout" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:background="@color/contact_card_line_color" 
      android:gravity="center_horizontal" 
      android:orientation="vertical"> 

      <TextView 
       android:layout_width="wrap_content" 
       android:layout_height="wrap_content" 
       android:text="@string/no_internet_connection" 
       android:textColor="@color/contact_card_initial_color" 
       android:textSize="@dimen/banner_text_size" /> 
     </LinearLayout> 

     <FrameLayout 
      android:id="@+id/fragment_holder" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_below="@+id/banner_layout"> 

     </FrameLayout> 


     </LinearLayout> 
関連する問題