【问题标题】:How to make button visible in video view "OnPreparedListener" method如何使按钮在视频视图“OnPreparedListener”方法中可见
【发布时间】:2013-06-09 22:48:29
【问题描述】:

我的活动中有播放按钮和视频视图。在 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>

【问题讨论】:

  • 请不要在您的问题中编辑答案。如果您找到了解决方案,请将其发布为答案并将其标记为已接受。

标签: android button android-videoview


【解决方案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);
            }
        });

希望这会有所帮助:)

【讨论】:

  • 我也试过了也没用,我找到了解决方案,在我的问题中更新了......
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-04-20
  • 1970-01-01
  • 2022-08-13
  • 1970-01-01
相关资源
最近更新 更多