简体   繁体   English

viewpager中的片段,找不到视图错误

[英]fragments in viewpager, no view found error

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. 在此对话框中,有一个Viewpager,它包含一些要显示的片段。

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 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 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 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: 这是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 

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 . 唯一的主要区别是你应该使用DialogFragment而不是Dialog ,这样你就可以调用getChildFragmentManager()并从DialogFragment接收正确的FragmentManager

Even though you were using getChildFragmentManager() before, it was coming from MyFragment and the PagerDialog class was not a child fragment in MyFragment . 即使您正在使用getChildFragmentManager()之前,它是从哪里来MyFragmentPagerDialog类是不是在孩子片段MyFragment

I have tested the code below, and it should be working fine now. 我已经测试了下面的代码,现在应该可以正常工作了。

MyFragment 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 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 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 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 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 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>

I found in Google a blog post, it says that viewpager doesn't work on Dialog. 我在Google上发现了一篇博文,它说viewpager不适用于Dialog。 It also says we should use DialogFragment instead. 它还说我们应该使用DialogFragment。

Here is the link to that blog: http://www.intellicode.in/viewpager-inside-dialog/ 以下是该博客的链接: http//www.intellicode.in/viewpager-inside-dialog/

getChildFragmentManager() is available since API 17 while you're using the v4 support library. 当您使用v4支持库时, getChildFragmentManager()在API 17之后可用。 Try using the support fragment manager instead: 请尝试使用支持片段管理器:

PagerDialog dialog = new PagerDialog(getActivity(),
        getActivity().getSupportFragmentManager());

The Dialog class is the base class for dialogs, but you should avoid instantiating Dialog directly. Dialog类是对话框的基类,但您应该避免直接实例化Dialog。 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. AlertDialogA对话框,可显示标题,最多三个按钮,可选项列表或自定义布局。 And also DatePickerDialog or TimePickerDialog. 还有DatePickerDialog或TimePickerDialog。

These classes define the style and structure for your dialog, but you should use a DialogFragment as a container for your dialog. 这些类定义对话框的样式和结构,但是您应该使用DialogFragment作为对话框的容器。 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. DialogFragment类提供了创建对话框和管理其外观所需的所有控件,而不是调用Dialog对象上的方法。

For more detail please go through Dialog Design 有关详细信息,请通过Dialog Design

The error sounds like it's looking for the id pager in the xml file for DummyFragment (fragment_dummy_layout.xml). 该错误听起来像是在DummyFragment(fragment_dummy_layout.xml)的xml文件中查找id寻呼机。 I wonder if this is due to calling View v = inflater.inflate(R.layout.fragment_dummy_layout, container, false); 我想知道这是否是由于调用View v = inflater.inflate(R.layout.fragment_dummy_layout, container, false); in the same file as setContentView(R.layout.dialog); 在与setContentView(R.layout.dialog);相同的文件中setContentView(R.layout.dialog); . Have you tried separating DummyFragment into it's own file? 你有没有尝试将DummyFragment分成它自己的文件?

You could also try 你也可以试试

View v = getActivity().getLayoutInflater().inflate(R.layout.fragment_dummy_layout, 
        container, false);

Try using DialogFragment and pass getChildFragmentManager() to your FragmentPagerAdapter's constructor. 尝试使用DialogFragment并将getChildFragmentManager()传递给FragmentPagerAdapter的构造函数。

DialogFragment: 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;
    }


}

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. 提示:如果需要自定义对话框,则可以将“活动”显示为对话框,而不是使用“对话框API”。 Simply create an activity and set its theme to Theme.Holo.Dialog in the manifest element: 只需创建一个活动并将其主题设置为清单元素中的Theme.Holo.Dialog:

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

Based on this tip, I don't make PagerDialog extend Dialog but from Fragment. 根据这个提示,我不会使PagerDialog扩展Dialog,而是来自Fragment。 And then put this Fragment inside an Activity , set the theme of this activity as above in AndroidManifest.xml. 然后将此Fragment放入Activity中,在AndroidManifest.xml中设置此活动的主题如上所述。

The updated code for the PagerDialog is as followed. PagerDialog的更新代码如下。

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. 我是Android编程的新手,我很高兴向大家学习。

Cheers. 干杯。

I think you used 我觉得你用过

Dialog dialog = new Dialog(context);

Instends this. 这样做。

1st Step: Used DialogFragment 第1步:使用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 第二步:设置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 : 第3步: 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 : 第4页如何使用此对话框碎片

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM