我想使用这些代码来自定义exoplayer的用户界面
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/exoplayer"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:controller_layout_id="@layout/control_view_normal"/>
这是control_view_normal,对应于app:controller_layout_id
然后我尝试在代码中找到 exo_fullscreen_button
View controlView = videoView.findViewById(R.id.exo_controller);
controlView.findViewById(R.id.exo_fullscreen_button)
.setOnClicklistener(v -> { //null pointer exception! why?
((activity)context).setRequestedOrientation(activityInfo.SCREEN_ORIENTATION_LANDSCAPE);
});
此外,编译器给我一个controlView.findViewById(R.id.exo_fullscreen_button)
为空指针。
有人知道如何在自定义布局中找到自定义按钮吗?