Android 如何在cardview和onclicklistener中设置预加载的视频图片?

Android 如何在cardview和onclicklistener中设置预加载的视频图片?,android,webview,android-cardview,android-youtube-api,Android,Webview,Android Cardview,Android Youtube Api,我已经在webview中成功加载了视频,它也在播放,但我想将该链接传递到其他活动,这些活动将使用AndroidOutubeplayer播放视频,并且我想显示该webview,如下所示 问题: 如何像下面这样显示视频 如何设置OnclickListner以将链接传递给其他活动 发送指向新活动的链接 CardView cardView = (CardView) findViewById(R.id.cardViewDemo1); cardView.setOnClickListener(ne

我已经在webview中成功加载了视频,它也在播放,但我想将该链接传递到其他活动,这些活动将使用AndroidOutubeplayer播放视频,并且我想显示该webview,如下所示

问题:

  • 如何像下面这样显示视频
  • 如何设置OnclickListner以将链接传递给其他活动

  • 发送指向新活动的链接

    CardView cardView = (CardView) findViewById(R.id.cardViewDemo1);
    
        cardView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
    
                String linkVideo = "Here, you set this string with link your video ";
    
                Bundle bundle = new Bundle();
                //HERE, YOU SET YOUR LINK VIDEO, INSIDE KEY "myKeyForReciveLinkVideo";
                bundle.putString("myKeyForReciveLinkVideo",linkVideo);
    
                //START YOUR ACTIVITY
                Intent i = new Intent(YourActivity,YourActivityGo.class);
               //Send your bundle containing the string with the url link to the new activity.
                startActivity(i,bundle);
    
            }
        });
    
        //Retrieve the arguments passed to new activity.
    
        Bundle bundle = new Bundle(getArguments());
    
        //Use the key you previously defined in the bundle to retrieve the url link string.
    
        String urlLink = bundle.getString("myKeyForReciveLinkVideo");
    
    要恢复传递给活动的数据,请在活动内执行

    CardView cardView = (CardView) findViewById(R.id.cardViewDemo1);
    
        cardView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
    
                String linkVideo = "Here, you set this string with link your video ";
    
                Bundle bundle = new Bundle();
                //HERE, YOU SET YOUR LINK VIDEO, INSIDE KEY "myKeyForReciveLinkVideo";
                bundle.putString("myKeyForReciveLinkVideo",linkVideo);
    
                //START YOUR ACTIVITY
                Intent i = new Intent(YourActivity,YourActivityGo.class);
               //Send your bundle containing the string with the url link to the new activity.
                startActivity(i,bundle);
    
            }
        });
    
        //Retrieve the arguments passed to new activity.
    
        Bundle bundle = new Bundle(getArguments());
    
        //Use the key you previously defined in the bundle to retrieve the url link string.
    
        String urlLink = bundle.getString("myKeyForReciveLinkVideo");
    

    我希望这对您有所帮助。

    如何使cardView像上面那样出现?这可能是一个预加载的映像,请尝试使用其API加载映像