我有以下活動:展會活動的看法覆蓋的FrameLayout與片段
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="es.xxx.xxx.MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:background="#CCFF0000"
android:id="@+id/lyNetworkError">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="No hay conexión a internet"
android:textAlignment="center"/>
</LinearLayout>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="@+id/container"/>
</RelativeLayout>
在它的FrameLayout應用程序將加載其他片段。
這是活動的onCreate代碼
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Constants.setAppContext(this);
setContentView(R.layout.activity_main);
Log.d("LoadFragment", "1 "+ loadFragment);
if (savedInstanceState == null) {
getSupportFragmentManager().beginTransaction().replace(R.id.container, new MainFragment()).commit();
}
IntentFilter filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
registerReceiver(networkStateReceiver, filter);
fragmentManager = getSupportFragmentManager();
lyNetworkError = (LinearLayout) findViewById(R.id.lyNetworkError);
}
的問題是LinearLayout中(包含TextView中)不顯示(更多鈔票是該片段渲染過的LinearLayout,因爲如果我刪除getSupportFragmentManager().beginTransaction().replace(R.id.container, new MainFragment()).commit();
的LinearLayout中出現)
那麼,如何顯示LinarLayout片段(在FrameLayout中加載)?
謝謝,它的工作原理。我知道在RelativeLayout中的順序很重要。謝謝 – RdlP 2014-09-25 20:41:42