Skip to content Skip to sidebar Skip to footer

Can't Click On Listview Whose Rows Are Made Of Webviews

I have an Activity which extends ListView The ListView that I use is an extension of ArrayAdapter and each row of the ListView primarily consists of a WebView The problem is that t

Solution 1:

If you add a focusable element to a ListView, it causes the ListView items to no longer be selectable. Try setting android:clickable = false on your WebView.

Solution 2:

Just make your onTouch event to do whatever you want.

e.g: My list item consists of TextView, WebView and Linear layout:

<LinearLayoutxmlns:android="http://schemas.android.com/apk/res/android"android:layout_width="match_parent"android:layout_height="66dp"android:orientation="vertical"android:id="@+id/layout"><TextViewandroid:layout_width="wrap_content"android:id="@+id/textView"android:layout_height="wrap_content" /><WebViewandroid:id="@+id/webvie"android:layout_width="match_parent"android:layout_height="wrap_content"></WebView></LinearLayout>

and I want to perform on click action - on the whole listitem.

 holder.layout.setOnClickListener(newView.OnClickListener() {
            @OverridepublicvoidonClick(View view) {
                //do stuff
            }
        });

But when I run my app, only texview is clickable. What to do? Set up onTouch listener on webView:

holder.webView.setOnTouchListener(newView.OnTouchListener() {
            @OverridepublicbooleanonTouch(View v, MotionEvent event) {
                holder.layout.callOnClick();
                returntrue;
            }
        });

supports only API 15+ tough...

Post a Comment for "Can't Click On Listview Whose Rows Are Made Of Webviews"