2017-01-10 42 views
0

我有一個應用程序,用戶可以在其中進行預訂。我想實現一個對話框,用戶可以通過定製自己的瀏覽預訂,即在dailog中創建一個片段

  1. 選擇的日期
  2. 添加額外
  3. 查看報價
  4. 確認訂房

我寫了一個佈局來顯示導航步驟給用戶(前進,後退,取消等),但我想要上面提到的步驟有它自己的片段/佈局。我還應該提到,創建對話框的初始調用是來自一個片段。 有誰知道如何做到這一點?我得到發現Fragment-bookingCustomization_DatePicker錯誤

private Dialog dialog; 
private void BtnMakeBooking_Click(object sender, EventArgs e) 
{ 
    dialog = new Dialog(this.Activity); 
    dialog.RequestWindowFeature((int)WindowFeatures.ContextMenu); 
    dialog.SetTitle("Booking Customization"); 
    dialog.SetContentView(Resource.Layout.Fragment_booking_customization); 

    Fragment_bookingCustomization_DatePicker date = new Fragment_bookingCustomization_DatePicker(); 
    var fragManager = FragmentManager.BeginTransaction(); 
    fragManager.Replace(Resource.Id.relativeLayout1, date); 
    fragManager.Commit(); 

    dialog.Show(); 
} 

Fragment_booking_customization.axml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:minWidth="25px" 
    android:minHeight="25px"> 
    <RelativeLayout 
     android:minWidth="25px" 
     android:minHeight="25px" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/relativeLayout1" /> 
    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="0dip" 
     android:orientation="horizontal" 
     android:layout_weight="1"> 
     <Button 
      android:text="Back" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="4dp" 
      android:layout_weight="1" 
      android:background="@drawable/red_button" 
      android:drawableLeft="@drawable/ic_action_previous_item" 
      android:id="@+id/btn_bookingcustomization_cancel" /> 
     <Button 
      android:text="Next" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" 
      android:layout_margin="4dp" 
      android:layout_weight="1" 
      android:background="@drawable/red_button" 
      android:drawableRight="@drawable/ic_action_next_item" 
      android:id="@+id/btn_bookingcustomization_next" /> 
    </LinearLayout> 
    <Button 
     android:text="Confirm Booking" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:background="@drawable/red_button" 
     android:drawableRight="@drawable/ic_action_accept" 
     android:id="@+id/btn_bookingcustomization_confirm" 
     android:layout_marginLeft="15dp" 
     android:layout_marginRight="15dp" 
     android:layout_marginTop="4dp" 
     android:layout_marginBottom="4dp" /> 
    <Button 
     android:text="Cancel" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_marginLeft="15dp" 
     android:layout_marginRight="15dp" 
     android:layout_marginTop="4dp" 
     android:layout_marginBottom="4dp" 
     android:background="@drawable/red_button" 
     android:drawableRight="@drawable/ic_action_remove" 
     android:id="@+id/btn_bookingcustomization_cancel" /> 
</LinearLayout> 

enter image description here

Fragment_bookingCustomization_DatePicker.axml

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="vertical" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:minWidth="25px" 
    android:minHeight="25px"> 
    <DatePicker 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/datePicker1" /> 
</LinearLayout> 
一個無景觀10個

Fragment_bookingCustomization_DatePicker.cs

public class Fragment_bookingCustomization_DatePicker : Fragment 
{ 
    public override void OnCreate(Bundle savedInstanceState) 
    { 
     base.OnCreate(savedInstanceState); 

     // Create your fragment here 
    } 

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

回答

0

我寫了一個佈局,以顯示導航步驟給用戶(前進,後退,取消等),但我想上面提到的步驟,有它自己的片段/佈局。我還應該提到,創建對話框的初始調用是來自一個片段。

從您的代碼中,您試圖直接從原始片段開始一個新的片段,根據您的要求這也是不可能的。因此,簡單地註釋掉開始新片段的代碼將會使您的項目發揮作用。

​​

如果你想知道如何開間接來自其他片段的片段,你可以參考this case