gpt4 book ai didi

android - YouTube Player 内选项卡式 Activity

转载 作者:行者123 更新时间:2023-11-30 00:38:36 26 4
gpt4 key购买 nike

我正在创建一个带有选项卡式 Activity 的应用,我想将 YouTube 播放器放在第三个选项卡上。

目前我有这个java代码:

public class FragmentTutorial extends Fragment {

public FragmentTutorial() {
// Required empty public constructor
}

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {

// Inflate the layout for this fragment
return inflater.inflate(R.layout.fragment_tutorial, container, false);
}

}

这是我的 XML:

<FrameLayout 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"
tools:context="com.example.examplecom.FragmentTutorial">

</FrameLayout>

我的问题是...

大多数教程都尝试使用这个 extends 语句:

public class FragmentTutorial extends YouTubeBaseActivity {

在我的例子中,我仍然需要 Fragment 作为 extends 语句。如果它更改为 YouTubeBaseActivity,我的代码将不会运行。

知道如何在 fragment 中添加 youtube 播放器,特别是在这样的选项卡式 Activity 中吗?

谢谢

最佳答案

您的 FragmentTutorial 应该扩展 YouTubePlayerFragment。

关于android - YouTube Player 内选项卡式 Activity ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42953759/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com