我的活动中有播放按钮和视频。在xml中,我使按钮不可见。在java代码中,我试着让它可见。
在视频观看的OnPreparedListener
方法中,我试图让它可见。但它不可见。下面是我的代码。
vvVideos.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
btnPlay.setVisibility(Button.VISIBLE);
}
});
XML文件::
<RelativeLayout
android:id="@+id/bottomll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<VideoView
android:id="@+id/videoView"
android:layout_width="fill_parent"
android:layout_height="150dp"/>
<Button
android:id="@+id/btnPlay"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:background="@drawable/play"
android:visibility="gone"/>
</RelativeLayout>
答案 0 :(得分:1)
而不是这个::
vvVideos.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
btnPlay.setVisibility(Button.VISIBLE);
}
});
使用此功能并尝试::
vvVideos.setOnPreparedListener(new OnPreparedListener() {
public void onPrepared(MediaPlayer mp) {
btnPlay.setVisibility(View.VISIBLE);
}
});
希望这会有所帮助:)