我正在使用VideoView将布局扩展到ViewPager。
以下是instantiateItem
函数中的代码:
RelativeLayout v = (RelativeLayout) li.inflate(R.layout.background34, null);
vv = (VideoView)v.findViewById(R.id.videoView);
Uri video = Uri.parse("android.resource://" + context.getPackageName() + "/" + R.raw.advetime);
MediaController mc = new MediaController(context);
mc.setAnchorView(vv);
mc.setMediaPlayer(vv);
vv.setMediaController(mc);
mc.show(0);
vv.setVideoURI(video);
vv.start();
我的应用在第mc.show(0)
行崩溃且出错:
E/AndroidRuntime(24284): FATAL EXCEPTION: main
E/AndroidRuntime(24284): android.view.WindowManager$BadTokenException: Unable to add window -- token null is not valid; is your activity running?
有什么问题?请帮帮我。