Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have an Activity called summaryActivity includes a fragment called completionFragment which has a popup called payment popup which has an EditText component when focus to it I need to display the datePicker as popup inside the payment popup (PaymentDialog)

SummaryLayout => Completion Fragment => Payment popup (Dialog) => datepicker (Fragment + DialogFragment)

here is my code:

Add Payment Details Layout:

    <?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/white"
    android:focusable="true"
    android:focusableInTouchMode="true">
    <FrameLayout
        android:layout_width="500dp"
        android:layout_height="600dp"
        android:layout_gravity="center_horizontal">
        <LinearLayout
            android:orientation="vertical"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content">
            <TextView
                android:text="@string/PaymentDetails"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:textColor="@color/blueclick"
                android:layout_marginTop="20dp"
                android:layout_marginLeft="10dp"
                android:textSize="20dp" />
            <View
                android:layout_width="fill_parent"
                android:layout_height="2dp"
                android:background="@color/blueclick" />
        <!-- Payment Layout -->
            <LinearLayout
                android:orientation="vertical"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:layout_marginLeft="20dp"
                android:layout_marginRight="10dp"
                android:layout_marginTop="10dp"
                android:id="@+id/linearLayout12">
                <LinearLayout
                    android:orientation="horizontal"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="20dp"
                    android:layout_marginTop="10dp"
                    android:layout_weight="0.5"
                    android:id="@+id/linearLayout13">
                    <TextView
                        android:text="@string/NameOnCard"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:minWidth="140dp"
                        android:textColor="@android:color/black"
                        android:id="@+id/textView12" />
                    <EditText
                        android:inputType="text"
                        android:layout_width="fill_parent"
                        android:background="@drawable/newBorder"
                        android:lines="1"
                        android:layout_marginLeft="10dp"
                        android:textColor="@android:color/black"
                        android:layout_height="wrap_content"
                        android:id="@+id/txtNameOnCard" />
                </LinearLayout>

                <LinearLayout
                    android:orientation="horizontal"
                    android:layout_width="fill_parent"
                    android:layout_height="wrap_content"
                    android:layout_marginLeft="20dp"
                    android:layout_marginTop="10dp"
                    android:layout_weight="0.5"
                    android:id="@+id/linearLayout17">
                    <TextView
                        android:text="@string/ExpirationDate"
                        android:minWidth="110dp"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:textColor="@android:color/black"
                        android:id="@+id/textView16" />
                    <EditText
                        android:inputType="text"
                        android:layout_width="fill_parent"
                        android:background="@drawable/newBorder"
                        android:lines="1"
                        android:layout_marginLeft="10dp"
                        android:textColor="@android:color/black"
                        android:layout_height="wrap_content"
                        android:id="@+id/txtExpirationDate" />
                </LinearLayout>
              </LinearLayout>
            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="fill_parent"
                android:layout_height="wrap_content"
                android:id="@+id/linearLayout1"
                android:layout_marginTop="20dp"
                android:minHeight="40dp">
                <Button
                    android:text="@string/Cancel"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:id="@+id/sequenceCancelButton"
                    android:textColor="@android:color/black"
                    android:background="@drawable/cancel_button"
                    android:layout_weight="1" />
                <Button
                    android:text="@string/Save"
                    android:layout_width="wrap_content"
                    android:layout_height="fill_parent"
                    android:id="@+id/sequenceSaveButton"
                    android:textColor="@android:color/black"
                    android:background="@drawable/cancel_button"
                    android:layout_weight="1" />
            </LinearLayout>
        </LinearLayout>
    </FrameLayout>
    <FrameLayout
        android:id="@+id/fragment_container"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:saveEnabled="false"
        android:background="@android:color/white" />
</LinearLayout>

Payment Dialog (Popup):

public class PaymentDialog: BaseDialog
{


readonly Activity activity;
    FrameLayout fragment_container;


    public PaymentDialog (Activity activity)
        : base (activity)
    {
        this.activity = activity;
    }

    protected override void OnCreate (Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
    SetContentView (Resource.Layout.AddPaymentDetailsLayout);
            SetCancelable (true);

            var cancel = (Button)FindViewById (Resource.Id.sequenceCancelButton);
            cancel.Click += (sender, e) => Dismiss ();
            //LinearLayout layout =  (LinearLayout)FindViewById (Resource.Id.dtpExpirationDateLayout); 

            EditText txtExpirationDate =  (EditText)FindViewById (Resource.Id.txtExpirationDate);

            fragment_container = (FrameLayout)FindViewById(Resource.Id.fragment_container);



            txtExpirationDate.ShowSoftInputOnFocus = false;
            txtExpirationDate.FocusChange +=txtExpirationDate_FocusChange;

        void txtExpirationDate_FocusChange(object sender, View.FocusChangeEventArgs e)
        {
            if (e.HasFocus)
            {
            var fragment = activity.FragmentManager.FindFragmentById<ConfirmationFragment>(Resource.Id.contentFrame);

            var fragTx = fragment.ChildFragmentManager.BeginTransaction();
                        var frag = new DatePickerFragment ();
                        fragTx.Add(fragment_container.Id, frag);
                        fragTx.Commit ();
            }
        }

So when I need to focus on the date field inside payment popup the fragment after it committed gives the following error "No view found for id 0x7f0b007d (com.MyProjectName:id/fragment_container) for fragment DatePickerFragment{4266acd8 #0 id=0x7f0b007d}"

share|improve this question

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.