如何在cardview和onclicklistener中设置预加载视频图片?
How to set preloaded video pic in cardview and onclicklistener to it?
我已经在 webview 中成功加载了视频,它也在播放,但我想将那个 link 传递给其他 Activity,它将使用 androidYouTubePlayer 播放视频,我也想显示那个网页视图如下。
问题:
- 如何显示如下视频
- 如何设置 OnclickListner 以将 link 传递给其他 activity。
<android.support.v7.widget.CardView
android:id="@+id/cardViewDemo1"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_margin="5dp"
android:background="#00ff00"
android:elevation="3dp"
app:cardCornerRadius="5dp">
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp" />
</android.support.v7.widget.CardView>
将您的 link 发送到新的 activity。
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);
}
});
要在 activity.
中恢复传递给您 activity 的数据
//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");
希望对您有所帮助。
我已经在 webview 中成功加载了视频,它也在播放,但我想将那个 link 传递给其他 Activity,它将使用 androidYouTubePlayer 播放视频,我也想显示那个网页视图如下。
问题:
- 如何显示如下视频
- 如何设置 OnclickListner 以将 link 传递给其他 activity。
<android.support.v7.widget.CardView
android:id="@+id/cardViewDemo1"
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_margin="5dp"
android:background="#00ff00"
android:elevation="3dp"
app:cardCornerRadius="5dp">
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp" />
</android.support.v7.widget.CardView>
将您的 link 发送到新的 activity。
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);
}
});
要在 activity.
中恢复传递给您 activity 的数据 //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");
希望对您有所帮助。