Java 如何在Android中创建一个简单的视频播放器?
我试图用Android创建一个简单的视频播放器,但遇到了麻烦。当我切换手机屏幕时,程序会再次开始播放视频。视频无法继续播放。 请帮我解决这个问题。对不起,我的英语不好。谢谢:D 这是xml文件Java 如何在Android中创建一个简单的视频播放器?,java,android,video,Java,Android,Video,我试图用Android创建一个简单的视频播放器,但遇到了麻烦。当我切换手机屏幕时,程序会再次开始播放视频。视频无法继续播放。 请帮我解决这个问题。对不起,我的英语不好。谢谢:D 这是xml文件 <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent" > &
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<VideoView
android:id="@+id/videoView1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="center" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:gravity="center" >
<ImageButton
android:id="@+id/imageButton1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/play" />
<ImageButton
android:id="@+id/imageButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/pause" />
<ImageButton
android:id="@+id/imageButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/stop" />
</LinearLayout>
在你的活动中使用这个
@Override
public void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
}
您必须在活动的清单上定义ConfifcChanges
<activity android:name="MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
>
</activity>
谢谢您的帮助。我做了,但没有改变任何事情。我该怎么处理这个?我是Android新手。复制上面的内容,并将其用于您的活动中@user2874223让我们假设在按钮停止方法之后..哦,对不起,我错了,它工作正常,非常感谢:D@user2874223很好,我很高兴能帮助你们。:)请相信,若答案是有用的接受,以便它可能也有用的其他人谁寻找这个。
<activity android:name="MainActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
>
</activity>