2013-04-18 45 views
5

Tôi có Bố cục tuyến tính chỉ chứa WebView. Những gì tôi muốn làm là để vô hiệu hóa các nhấp chuột trong Webview, có nghĩa là tôi muốn sự kiện được gọi là liên kết với RelativeLayout bg_stepsContainer. Tôi đã sử dụng android: clickable = "false" Đây là mãLàm cách nào để vô hiệu hóa Nhấp vào WebView?

<RelativeLayout 
        android:layout_width="match_parent" 
        android:layout_height="wrap_content" 
        android:minHeight="30dp" 
        android:layout_marginLeft="5dp" 
        android:layout_marginRight="5dp" 
        android:layout_marginTop="5dp" 
        android:layout_marginBottom="5dp" 
        android:id="@+id/bg_stepsContainer" 
        > 

       <LinearLayout 
        android:id="@+id/stepslcontainer" 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:layout_alignParentLeft="true" 
        android:layout_alignParentTop="true" 

        android:clickable="false" 
        android:focusable="false" 
        android:focusableInTouchMode="false" > 

        <WebView 
         android:id="@+id/bg_stepsToReproduce" 
         android:layout_width="wrap_content" 
         android:layout_height="wrap_content" 
         android:clickable="false" 
         android:focusable="false" 
         android:focusableInTouchMode="false" 

         android:textColor="@color/solid_black" /> 

        </LinearLayout> 
        <ImageView 
         android:id="@+id/stepsArrow" 
         android:layout_width="10dp" 
         android:layout_height="10dp" 
         android:layout_alignParentRight="true" 
         android:clickable="false" 
         android:layout_marginRight="10dp" 
         android:layout_marginLeft="10dp" 
         android:layout_centerVertical="true" 
         android:src="@drawable/ic_right_arrow" /> 

</RelativeLayout> 

Bất kỳ đề xuất nào được đánh giá cao!

+0

có thể điều này giúp bạn http://stackoverflow.com/questions/4415528/how-to-pass-the-onclick-event-to-its-parent-on-android –

+0

http://stackoverflow.com/questions/3853794/disable-webview-touch-events-in-android điều này sẽ hữu ích –

Trả lời

20
mWebView.setOnTouchListener(new View.OnTouchListener() { 
    @Override 
    public boolean onTouch(View v, MotionEvent event) { 
     return true; 
    } 
}); 

Sử dụng android: clickable = "false" không tắt các sự kiện chạm.

+0

Một lần nữa làm thế nào để kích hoạt các sự kiện liên lạc xin vui lòng giúp tôi .. –

+0

@GowthamanM chỉ cần loại bỏ 'OnTouchListener' từ webview. – ubuntudroid

Các vấn đề liên quan