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