das ist mein activity_main.xmlwie eine lineare Anordnung des activity_main.xml in einem Fragment zugreifen
<?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>
In meiner Haupttätigkeit, ich
setContentView(R.layout.activity_launch_view);
fragment.setArguments(getIntent().getExtras());
getFragmentManager().beginTransaction().replace(R.id.fragment_holder, fragment).commit();
In meinem Fragment,
1) konnte nicht die no Internet-Verbindung Text standardmäßig 2) Ich kann auf sie zugreifen, keine Laufzeitfehler, konnte aber den Text nicht sehen.
Der Grund ist, dass Sie die Textview vor framelayout platziert, so dass die framelayout den dieses Problem Ort Textview nach dem Frame-Layout textView.To lösen verbirgt. – Vishwa
verwenden Sie Schnittstelle für jedes Ereignis für lineares Layout aus Fragment –