views:

167

answers:

1

Hi ,

I have Android LisView that was contain TextView to display the data in the list,

I add to change it to Webview, after doing that everything look good except the setOnClickListener that not responding anymore..

I have read about the Webview and found that setOnClickListener is not supported, instead setOnTouchListener is supported is there

a way to use the same functionality as setOnClickListener in Android WebView ?

Like this:

  myWebView.setOnClickListener(new OnClickListener(){ 
                          @Override 
                          public void onClick(View v) {

                          //do it ..

                          } 
                        }); 

Thanks (:

A: 

Why not use onTouch listener as you stated?

myWebView.setOnTouchListener(new OnTouchListener() {

        @Override
        public boolean onTouch(View v, MotionEvent event) {
            // TODO Auto-generated method stub
            return false;
        }
    });
Konstantin Burov
Thanks Konstantin, maybe I miss something with the onTouch event I try it and it didn't work the way I need it.I have list that can be scroll,every item in the list open webpage when using the onTouch event while scrolling down the listView the onTouch event is fire,I can't scroll down,scroll down the list fire the onTouch event, I want to be able scrolling to the bottom of the list and then click.
Zohar Adar
You have to investigate the MotionEvent, base on the info you should be able to determine if user actually tries to scroll or just touched the screen. If that's scrollig just return true to let webview act as usual.
Konstantin Burov
Thanks Konstantin,Its look like MotionEvent.ACTION_UP do the work for the webview.The thing that is each item in the listview contain two webview's and two textview's,When using the onTouchEvent for single webview it work good but in this way I need to add onTouchEvent for each item,So I tried to use the onTouchEvent to myView.setOnTouchListener like this I can call it only one time for each row but doing that I am not getting any response.
Zohar Adar