-1

私は自分の画像ボタンを見えるようにしようとしていて、ユーザーがビデオ画面に触れると目に見えないようにしようとしています(私はアンドロイドスタジオでビデオを再生するためにビデオビューを使用しています)。ビデオ画面が表示され、もう一度触れると画像ボタンが見えなくなります。ユーザーがビデオ画面に触れると、ビデオビューで画像ボタン(キャンセルボタン)を非表示にしたり非表示にする方法はありますか?

おかげ

@Override 
    public boolean onTouchEvent(MotionEvent event) { 
     but1= (Button)findViewById(R.id.imageButtonBack); 
     if (event.getAction() == MotionEvent.ACTION_DOWN) { 

      but1.setVisibility(View.VISIBLE); 
     } 
     if (event.getAction() == MotionEvent.ACTION_UP) { 

      but1.setVisibility(View.INVISIBLE); 
     } 
     return super.onTouchEvent(event); 
    } 
私は、次のコードを使用するが、私はそれは、残念ながら、あなたのアプリが動作を停止し、背面の主な活動(終値プレーヤーの活動)に私を返すと言うビデオをタッチしたとき!専門家はどのようにこの問題を解決するために私に言うことができます

activity_player.xml

<?xml version="1.0" encoding="utf-8"?> 
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:id="@+id/activity_player" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent"> 




    <VideoView android:id="@+id/videoView" 
     android:layout_width="fill_parent" 
     android:layout_alignParentRight="true" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     android:layout_alignParentBottom="true" 
     android:layout_height="fill_parent"> 
    </VideoView> 

    <ImageButton 
     android:paddingLeft="5dp" 
     android:paddingTop="8dp" 
     android:layout_width="67dp" 
     android:layout_height="40dp" 
     android:id="@+id/imageButtonBack" 
     android:src="@drawable/donebutton_active" 
     android:visibility="gone" 
     android:onClick="donebutton" /> 
</RelativeLayout> 

答えて

0

findViewById、のonCreateでsetContentView(R.layout.xxx)の後に、このような

を呼び出すする必要があります:

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.xx); 
    but1= (Button)findViewById(R.id.imageButtonBack); 

} 
+0

お返事ありがとうございます。どのようにレイアウトを作成する必要はありませんか?私はアンドロイドプログラミングの初心者ですので、問題を解決するために必要な場合は、レイアウトを追加してください。 – user1788736

+0

[link](https://github.com/linsea/UniversalVideoView) – NateZh

+0

多分あなたは他の人のプロジェクトを最初に習得しようとすることができます。上記のように。 – NateZh

関連する問題