6

I have an activity holding a fragment, in this fragment there is a button , when it is clicked, a dialog is popped out.

In this dialog, there is a Viewpager, which holds some fragments to display.

Here are the code and the error, please spare your valuable time to show me where I am wrong. I much appreciate your help.

MainActivity.class

import android.os.Bundle;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;

public class MainActivity extends FragmentActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    FragmentManager fm = getSupportFragmentManager();
    FragmentTransaction fragmentTransaction = fm.beginTransaction();

    MyFragment fragment = new MyFragment();

    fragmentTransaction.add(R.id.container, fragment);

    fragmentTransaction.commit();

}
}

MyFragment.class

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup;
import android.widget.Button;

public class MyFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
        Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.fragment_sandbox, container, false);
    Button button = (Button) v.findViewById(R.id.button);

    button.setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View arg0) {
            PagerDialog dialog = new PagerDialog(getActivity(),
                    getChildFragmentManager());
            dialog.show();
        }
    });
    return v;
}
}

PagerDialog.class

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

public class PagerDialog extends Dialog {

ViewPager mViewPager;
FragmentStatePagerAdapter mAdapter;
FragmentManager mFragmentManager;

public PagerDialog(Context context, FragmentManager fm) {
    super(context);
    mFragmentManager = fm;
}

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.dialog);
    mViewPager = (ViewPager) findViewById(R.id.pager);
    mAdapter = new MyAdapter(mFragmentManager);
    mViewPager.setAdapter(mAdapter);

}

private class MyAdapter extends FragmentStatePagerAdapter {

    public MyAdapter(FragmentManager fm) {
        super(fm);

    }

    @Override
    public Fragment getItem(int index) {
        return new DummyFragment();
    }

    @Override
    public int getCount() {
        return 2;
    }

}

private class DummyFragment extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater,
            @Nullable ViewGroup container,
            @Nullable Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.fragment_dummy_layout,
                container, false);
        return v;
    }
}
}

Here is the dialog.xml:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

<android.support.v4.view.ViewPager
    android:id="@+id/pager"
    android:layout_width="match_parent"
    android:layout_height="match_parent" />

</LinearLayout>

Here is the error

03-06 19:43:38.487: E/AndroidRuntime(1167): FATAL EXCEPTION: main
03-06 19:43:38.487: E/AndroidRuntime(1167): Process: com.me.sandbox, PID: 1167
03-06 19:43:38.487: E/AndroidRuntime(1167): java.lang.IllegalArgumentException: No view found for id 0x7f05003d (com.mochimira.sandbox:id/pager) for fragment DummyFragment{b2d9f8c8 #0 id=0x7f05003d}
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:939)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1126)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:739)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1489)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.support.v4.app.FragmentManagerImpl.executePendingTransactions(FragmentManager.java:486)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.support.v4.app.FragmentStatePagerAdapter.finishUpdate(FragmentStatePagerAdapter.java:163)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.support.v4.view.ViewPager.populate(ViewPager.java:1073)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.support.v4.view.ViewPager.populate(ViewPager.java:919)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1441)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.View.measure(View.java:16497)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.View.measure(View.java:16497)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.View.measure(View.java:16497)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.View.measure(View.java:16497)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.View.measure(View.java:16497)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5125)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2291)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.View.measure(View.java:16497)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:1916)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1113)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1295)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1000)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:5670)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.Choreographer$CallbackRecord.run(Choreographer.java:761)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.Choreographer.doCallbacks(Choreographer.java:574)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.Choreographer.doFrame(Choreographer.java:544)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:747)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.os.Handler.handleCallback(Handler.java:733)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.os.Handler.dispatchMessage(Handler.java:95)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.os.Looper.loop(Looper.java:136)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at android.app.ActivityThread.main(ActivityThread.java:5017)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at java.lang.reflect.Method.invokeNative(Native Method)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at java.lang.reflect.Method.invoke(Method.java:515)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
03-06 19:43:38.487: E/AndroidRuntime(1167):  at dalvik.system.NativeStart.main(Native Method
Huy Than
  • 1,538
  • 2
  • 16
  • 31
  • Is there anything wrong in the way I ask ? I have no answer from you. – Huy Than Mar 05 '15 at 14:48
  • Hm no I do not see anything wrong with your question. But I do not see an obvious error tbh. The problem seems to be the ViewPager which can not be found by your Dialog. Can you try and add a Button or a TextView to the Dialog instead of the Pager? – Deutro Mar 05 '15 at 14:51
  • Double click on this error line in the logcat to bring you to that line that causes this error, then post here that line of code – frogatto Mar 05 '15 at 15:01
  • @Deutro: I did as you told. I add to a Button to the Dialog instead of the Pager to the Dialog and it shows as normally. No problem. You are right, it seems to be the ViewPager can not be found by the Dialog but I do not understand why. – Huy Than Mar 07 '15 at 00:43
  • @abforce: I have updated the error in the log, please have a look, when I double click on the error line. I can't go into the code because it is in the android APIs and it does not show in my eclipse. – Huy Than Mar 07 '15 at 01:04
  • What is ButtonFragment? – SilverCorvus Mar 07 '15 at 16:35
  • You have two fragments in adapter, one is `DummyFragment`, what's another? – Xcihnegn Mar 09 '15 at 10:20
  • @CurlyCorvus: sorry , my mistake, the ButtonFragment is MyFragment, I have edited the question :) – Huy Than Mar 10 '15 at 15:24
  • @Xcihnegn: 2 fragments in the adapter are dummy adapter, they are the same, I just put there to test if the code works. Thank you for your question. The bounty is still available, though I found a way to work around the problem, I still want to know why the original code does not work. :) – Huy Than Mar 10 '15 at 15:26
  • @user1525788 I do not go through all your codes, but there is one thing `Dialog` you should not do like that, look my answer, hope give you some idea. – Xcihnegn Mar 10 '15 at 15:46
  • try this? http://stackoverflow.com/a/8158916/1553254 – Nguyễn Hoài Nam Mar 11 '15 at 02:41

8 Answers8

18

I have found a solution to the problem and have modified your classes so that this error no longer occurs.

The only major difference was that you should use a DialogFragment instead of a Dialog, that way you have access to call getChildFragmentManager() and receive the correct FragmentManager from the DialogFragment.

Even though you were using getChildFragmentManager() before, it was coming from MyFragment and the PagerDialog class was not a child fragment in MyFragment.

I have tested the code below, and it should be working fine now.

MyFragment

public class MyFragment extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.fragment_sandbox, container, false);
        Button button = (Button) v.findViewById(R.id.button);

        button.setOnClickListener(new OnClickListener() {

            @Override
            public void onClick(View arg0) {
                DialogFragment newFragment = PagerDialog.newInstance();
                newFragment.show(getChildFragmentManager(), "dialog");
            }

        });

        return v;
    }
}

PagerDialog

public class PagerDialog extends DialogFragment {

    public static PagerDialog newInstance() {
        return new PagerDialog();
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.dialog_fragment, container, false);

        ViewPager mViewPager = (ViewPager) v.findViewById(R.id.view_pager);

        /* Use childFragmentManager here provided from the PagerDialog */
        MyAdapter mAdapter = new MyAdapter(getChildFragmentManager());
        mViewPager.setAdapter(mAdapter);

        return v;
    }

    private class MyAdapter extends FragmentStatePagerAdapter {

        public MyAdapter(FragmentManager fm) {
            super(fm);
        }

        @Override
        public Fragment getItem(int index) {
            return new DummyFragment();
        }

        @Override
        public int getCount() {
            return 2;
        }

    }
}

DummyFragment

public class DummyFragment extends Fragment {

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.fragment_dummy_layout, container, false);
        return v;
    }

}

fragment_sandbox.xml

<?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="match_parent"
    android:gravity="center">

    <Button
        android:id="@+id/button"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Test Fragment Dialog Pager"
        android:textSize="24sp"
        android:padding="20dp" />

</LinearLayout>

dialog_fragment.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center"
    android:orientation="vertical" >

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Fragment Dialog Title Text "
        android:padding="10dp"
        android:textColor="#333"
        android:textSize="24sp"/>

    <android.support.v4.view.ViewPager
        android:id="@+id/view_pager"
        android:layout_width="match_parent"
        android:layout_height="200dp"/>

</LinearLayout>

fragment_dummy_layout.xml

    <?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="match_parent"
    android:gravity="center">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Fragment Dummy Text"
        android:textSize="24sp"
        android:textColor="#ff0000"/>

</LinearLayout>
Andrea Thacker
  • 3,440
  • 1
  • 25
  • 37
1

I found in Google a blog post, it says that viewpager doesn't work on Dialog. It also says we should use DialogFragment instead.

Here is the link to that blog: http://www.intellicode.in/viewpager-inside-dialog/

Tien
  • 2,105
  • 17
  • 14
  • Thank you for your answer, I have replaced the ViewPager with a Fragment and it has the same error : "no view found " . To sum up the problem in my code, the ViewPager doesn't work on Dialog and a Fragment doesn't work on Dialog either. Intuitively, to me, it seems there is a problem with the nested fragments but I can't figure it out. – Huy Than Mar 07 '15 at 17:09
1

getChildFragmentManager() is available since API 17 while you're using the v4 support library. Try using the support fragment manager instead:

PagerDialog dialog = new PagerDialog(getActivity(),
        getActivity().getSupportFragmentManager());
Simas
  • 43,548
  • 10
  • 88
  • 116
1

The Dialog class is the base class for dialogs, but you should avoid instantiating Dialog directly. Instead, use one of the following subclasses:

AlertDialogA dialog that can show a title, up to three buttons, a list of selectable items, or a custom layout. And also DatePickerDialog or TimePickerDialog.

These classes define the style and structure for your dialog, but you should use a DialogFragment as a container for your dialog. The DialogFragment class provides all the controls you need to create your dialog and manage its appearance, instead of calling methods on the Dialog object.

For more detail please go through Dialog Design

Community
  • 1
  • 1
Xcihnegn
  • 11,579
  • 10
  • 33
  • 33
1

The error sounds like it's looking for the id pager in the xml file for DummyFragment (fragment_dummy_layout.xml). I wonder if this is due to calling View v = inflater.inflate(R.layout.fragment_dummy_layout, container, false); in the same file as setContentView(R.layout.dialog);. Have you tried separating DummyFragment into it's own file?

You could also try

View v = getActivity().getLayoutInflater().inflate(R.layout.fragment_dummy_layout, 
        container, false);
TTransmit
  • 3,270
  • 2
  • 28
  • 43
1

Try using DialogFragment and pass getChildFragmentManager() to your FragmentPagerAdapter's constructor.

DialogFragment:

public static class MyDialogFragment extends DialogFragment {

    private ViewPager viewPager;
    MySectionPagerAdapter mAdapter;

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.m_layout, container);

        viewPager = (ViewPager) view.findViewById(R.id.viewpager);
        mAdapter = new MySectionPagerAdapter(getChildFragmentManager());
        viewPager.setAdapter(mAdapter);

        return view;
    }


}
0

so far, we can't figure out why there is an error, but I have a way to work around this, using this tip:

Tip: If you want a custom dialog, you can instead display an Activity as a dialog instead of using the Dialog APIs. Simply create an activity and set its theme to Theme.Holo.Dialog in the manifest element:

<activity android:theme="@android:style/Theme.Holo.Dialog"

Based on this tip, I don't make PagerDialog extend Dialog but from Fragment. And then put this Fragment inside an Activity , set the theme of this activity as above in AndroidManifest.xml.

The updated code for the PagerDialog is as followed.

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentStatePagerAdapter;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

public class PagerDialog extends Fragment {

ViewPager mViewPager;
FragmentStatePagerAdapter mAdapter;

@Override
public View onCreateView(LayoutInflater inflater,
        @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View v = inflater.inflate(R.id.dialog, container, false);
    mViewPager = (ViewPager) v.findViewById(R.id.pager);
    mAdapter = new MyAdapter(getFragmentManager());
    mViewPager.setAdapter(mAdapter);
    return v;
}

private class MyAdapter extends FragmentStatePagerAdapter {

    public MyAdapter(FragmentManager fm) {
        super(fm);

    }

    @Override
    public Fragment getItem(int index) {
        return new DummyFragment();
    }

    @Override
    public int getCount() {
        return 2;
    }

}

private class DummyFragment extends Fragment {
    @Override
    public View onCreateView(LayoutInflater inflater,
            @Nullable ViewGroup container,
            @Nullable Bundle savedInstanceState) {

        View v = inflater.inflate(R.layout.fragment_dummy_layout,
                container, false);
        return v;
    }
}
}

If you have any better solutions or you can find out why the original code in my question does not work, please teach me. I am a newbie in Android programing and I am happy to learn from you all.

Cheers.

Huy Than
  • 1,538
  • 2
  • 16
  • 31
0

I think you used

Dialog dialog = new Dialog(context);

Instends this.

1st Step: Used DialogFragment

public class MyCustomDialog extends DialogFragment {
    Button mButton;
    EditText mEditText;


    List<MasterPageModel> listdata;
    int position;
    ViewPager viewpager;

    public MyCustomDialog(List<MasterPageModel> listdata, int position) {
        this.listdata = listdata;
        this.position = position;
    }




    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        final View dialog = inflater.inflate(R.layout.dailoglayout, container);

        final Dialog dailog = getDialog();
        dailog.getWindow().setLayout(LinearLayout.LayoutParams.FILL_PARENT, LinearLayout.LayoutParams.MATCH_PARENT);
        dailog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        dailog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,
                WindowManager.LayoutParams.FLAG_FULLSCREEN);

        ImageView closebtn = (ImageView) dialog.findViewById(R.id.closeimgeview);
        closebtn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                dailog.dismiss();
            }
        });

        viewpager = (ViewPager) dialog.findViewById(R.id.dailog_viewpager);

        **viewpager.setAdapter(new PagerAdapter(getChildFragmentManager(), listdata));** //This Line is Very important
        viewpager.setCurrentItem(position);

        return dialog;
    }


    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setStyle(DialogFragment.STYLE_NORMAL, android.R.style.Theme_Black_NoTitleBar_Fullscreen); //For Full Screen of DailogBox
    }

}

2nd Step :set The FragmentViewPager

public class PagerAdapter extends FragmentPagerAdapter   {

    private final List<MasterPageModel> pages;

    public PagerAdapter(FragmentManager fm, List<MasterPageModel> pages) {
        super(fm);
        this.pages = pages;
    }



    @Override
    public Fragment getItem(int position) {
        return new ViewPagerFragment(pages.get(position));
    }

    @Override
    public int getCount() {
        return pages.size();
    }
}

3rd Step : Fragment View For ViewPager:

public class ViewPagerFragment extends Fragment {

    MasterPageModel masteDetailModel;


    public ViewPagerFragment(MasterPageModel questionItem) {
        this.masteDetailModel = questionItem;
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View v = inflater.inflate(R.layout.pagerlayout, container, false);

        ImageView image = (ImageView) v.findViewById(R.id.pager_imageview);
        Log.i("Image", "=>" + masteDetailModel.imagelarge);
        Picasso.with(getActivity()).load(masteDetailModel.imagethumb).error(R.drawable.img).into(image);

        return v;
    }

4th How to Use this dialogfragment:

 MyCustomDialog fragment1 = new MyCustomDialog(listdata, position);
                EditionDetailActivity act = (EditionDetailActivity) context;
                FragmentManager fm = act.getSupportFragmentManager();
                fragment1.show(fm, "");