Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/203.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 如何将自定义SurfaceView添加到FragmentView中的FrameLayout_Android_Android Fragments_Fragment_Surfaceview_Android Framelayout - Fatal编程技术网

Android 如何将自定义SurfaceView添加到FragmentView中的FrameLayout

Android 如何将自定义SurfaceView添加到FragmentView中的FrameLayout,android,android-fragments,fragment,surfaceview,android-framelayout,Android,Android Fragments,Fragment,Surfaceview,Android Framelayout,我有一个具有FrameLayout的视图,在该视图中动态放置一个自定义的SurfaceView类。在其他常规活动中,我能够毫无问题地做到这一点。试图在片段中执行相同的操作会导致问题。当我尝试将SurfaceView添加到FrameLayout时,仅显示黑色。在尝试将其动态放置到ListView的FrameLayout中时也会发生这种情况,ListView也使用LayoutFlater。我相信问题就在那里,但我不知道如何解决这个问题 ViewGroup rootView = (ViewGroup)

我有一个具有FrameLayout的视图,在该视图中动态放置一个自定义的SurfaceView类。在其他常规活动中,我能够毫无问题地做到这一点。试图在片段中执行相同的操作会导致问题。当我尝试将SurfaceView添加到FrameLayout时,仅显示黑色。在尝试将其动态放置到ListView的FrameLayout中时也会发生这种情况,ListView也使用LayoutFlater。我相信问题就在那里,但我不知道如何解决这个问题

ViewGroup rootView = (ViewGroup) inflater
    .inflate(R.layout.view_the_graph, container);

// Add the graph to the view
GraphView = new GraphSurfaceView(getActivity(), false);
frame = (FrameLayout) rootView.findViewById(R.id.frameLayoutDisplay);
frame.addView(GrapView);