-1

사용자가 비디오 화면을 터치 할 때 내 이미지 단추를 보이거나 보이지 않게하려고합니다. (비디오보기를 사용하여 android studio에서 비디오를 재생합니다.) 처음에는 이미지 단추가 보이지 않지만 사용자가 건 드리면 보이게하고 싶습니다. 비디오 화면과 그가 다시 만져도 나는 이미지 버튼을 보이지 않게하고 싶습니다. 사용자가 비디오 화면을 터치 할 때 비디오보기에서 이미지 단추 (취소 단추)를 숨기거나 숨기기 해제하는 방법은 무엇입니까?

나는 다음과 같은 코드를 사용하지만 난이 비디오를 터치하면이 앱이 작동을 중지하고 전문가가 어떻게 해결하는 방법이 문제 감사

@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