Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/214.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
Java 如何在android对话框中设置视频视图_Java_Android_Android Videoview - Fatal编程技术网

Java 如何在android对话框中设置视频视图

Java 如何在android对话框中设置视频视图,java,android,android-videoview,Java,Android,Android Videoview,如何在带有片段的对话框中设置videoView 我尝试的是不工作(没有播放视频) 和fragment_fong.xml(videoView) 如何设置,感谢您的帮助视频未播放 LayoutInflater inflater = ((HomeActivity) context).getLayoutInflater(); View dialogLayout = inflater.inflate(R.layout.fragment_fong, null); Ale

如何在带有片段的对话框中设置videoView

我尝试的是不工作(没有播放视频)

和fragment_fong.xml(videoView)


如何设置,感谢您的帮助

视频未播放

 LayoutInflater inflater = ((HomeActivity) context).getLayoutInflater();
        View dialogLayout = inflater.inflate(R.layout.fragment_fong, null);
        AlertDialog.Builder builder = new AlertDialog.Builder(context);

        final AlertDialog dialog = builder.create();
        dialog.setView(dialogLayout);
        dialog.show();
       // dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        final VideoView video_player_view = (VideoView) dialog.findViewById(R.id.videos);

        WindowManager.LayoutParams lp = new WindowManager.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        lp.copyFrom(dialog.getWindow().getAttributes());
        dialog.getWindow().setAttributes(lp);

        Uri uri = Uri.parse("http://file2.video9.in/english/movie/2014/x-men-_days_of_future_past/X-Men-%20Days%20of%20Future%20Past%20Trailer%20-%20[Webmusic.IN].3gp");
        video_player_view.setVideoURI(uri);
        video_player_view.start();

更改:最终视频视图视频\u播放器\u视图=(视频视图)对话框;到最终的VideoView video\u player\u view=(VideoView)dialogLayout.findViewById(R.id.videos)@akhilesh0707还是错误视频视图显示了吗,但视频没有播放?@UsmanRana视频没有显示…你能发送截图吗?并尝试设置视图的固定宽度和高度,而不是包裹内容。ivideoView是否显示在这种情况下我有一些问题,现在视频显示和播放,但视频是改变颜色像一个背景对话框(纯色)。如何修复它
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:paddingBottom="@dimen/activity_vertical_margin"
    android:paddingLeft="@dimen/activity_horizontal_margin"
    android:paddingRight="@dimen/activity_horizontal_margin"
    android:paddingTop="@dimen/activity_vertical_margin">

    <VideoView
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:id="@+id/videos" />
</RelativeLayout>
 LayoutInflater inflater = ((HomeActivity) context).getLayoutInflater();
        View dialogLayout = inflater.inflate(R.layout.fragment_fong, null);
        AlertDialog.Builder builder = new AlertDialog.Builder(context);

        final AlertDialog dialog = builder.create();
        dialog.setView(dialogLayout);
        dialog.show();
       // dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        final VideoView video_player_view = (VideoView) dialog.findViewById(R.id.videos);

        WindowManager.LayoutParams lp = new WindowManager.LayoutParams(RelativeLayout.LayoutParams.WRAP_CONTENT, RelativeLayout.LayoutParams.WRAP_CONTENT);
        lp.copyFrom(dialog.getWindow().getAttributes());
        dialog.getWindow().setAttributes(lp);

        Uri uri = Uri.parse("http://file2.video9.in/english/movie/2014/x-men-_days_of_future_past/X-Men-%20Days%20of%20Future%20Past%20Trailer%20-%20[Webmusic.IN].3gp");
        video_player_view.setVideoURI(uri);
        video_player_view.start();