2016-04-19 17 views

Antwort

1

Das Problem ist, dass Sie ein Layout in Ihrem Anruf von transaction.Replace() sind vorbei, stattdessen sollten Sie die Id passieren die der Viewgroup wo Das Fragment wird in Ihr Layout eingefügt.

so das Layout der Aktivität sollte Ihre Fragmente, die wie folgt aussehen:

<?xml version="1.0" encoding="utf-8"?> 
    <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
     <FrameLayout 
      android:id="@+id/content_frame" 
      android:layout_width="match_parent" 
      android:layout_height="fill_parent" /> 
    </FrameLayout> 

Und in Ihrem FragmentStockSearch Fragment, außer Kraft setzen OnCreateView etwas wie folgt aus:

public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
{ 
    return inflater.Inflate(Resource.Layout.your_layout, null, false); 
} 

und schließlich Ihr Fragment Transaktionscode:

var trans = new FragmentManager.BeginTransaction(); 
trans.Replace(Resource.Id.content_frame, new FragmentStockSearch(), "FragmentStockSearch"); 
trans.AddToBackStack(null); 
trans.Commit(); 
Verwandte Themen