1

I have play button and videoview in my activity. In xml, I made the button as invisible. In java code I'm try to make it visible.

In video view's OnPreparedListener method I'm trying to make it visible. but its not getting visible. below is my code.

        vvVideos.setOnPreparedListener(new OnPreparedListener() {
            public void onPrepared(MediaPlayer mp) {
                btnPlay.setVisibility(Button.VISIBLE);
            }
        });

XML File ::

<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>
user229044
  • 232,980
  • 40
  • 330
  • 338
Vignesh
  • 2,295
  • 7
  • 33
  • 41
  • Please don't edit answers into your question. If you've found a solution, post it as an answer and mark it as accepted. – user229044 Aug 04 '15 at 12:37

1 Answers1

1

Instead of this ::

 vvVideos.setOnPreparedListener(new OnPreparedListener() {
            public void onPrepared(MediaPlayer mp) {
                btnPlay.setVisibility(Button.VISIBLE);
            }
        });

Use this and Try ::

 vvVideos.setOnPreparedListener(new OnPreparedListener() {
            public void onPrepared(MediaPlayer mp) {
                btnPlay.setVisibility(View.VISIBLE);
            }
        });

Hope this helps :)

AndroidLearner
  • 4,500
  • 4
  • 31
  • 62