Detect button click or touch from java webview android - android

In my activity I have webview and top of WebView there is a RelativeLayout which contains edittext and button. This RelativeLayout has to open/close when user touch on webview. The problem is that I can't detect where user touch in html content, for instance if user click the button in HTML , RelativeLayout shoudn't open but if user touch blank area in html then RelativeLayout will open. How can I detect user's touch is not in any touchable or clickable area in html content ?
HTML pages are not in my control so I couldn't build jafascriptinterface, I has to do in with Webview.

event.preventDefault();
if your menu uses a jquery function that toggles the areas visible..
ex. if you have an click function..
$(".menu-item").click(
function () {
event.preventDefault();
yourcodethattogglesmenu
}
);
Show your code first in the future, will help us understand and give a better answer.

If i understood you correctly, you want to show a native view (RelativeLayout) once a specific HTML element is clicked.
The only way to trigger JAVA code from HTML content is the JavascriptInterface. If you do not control the HTML stuff you are out.

Related

How to prevent Android's back gesture from selecting text inside of nested webview?

We have an app that uses a Webview to render a text editor (contentEditable) inside of a React Native application. This works well overall, except that the Android back gesture can lead to changes in the selection of text inside the Webview and similar strange behaviors.
We've tried things like having an element along the screen edge that pops out to overlay the Webview when a user begins a back gesture, tried with both onPress and onPressIn.
But by that time, it's already too late to evt.preventDefault() - and the text selection takes place even though the Webview is now covered by another element, I guess because it's technically still the same event that triggered the overlay. (Also tried evt.stopPropagation in desperation.)
Is there any way to prevent text selection within our Webview when a user uses the back gesture?

Navigation in WebView with keyboard

Is it possible to navigate through elements in WebView? For example if web page contains 3x3 grid with buttons, is it possible to select and press these buttons using key events?
Yes.You can enable javascript for your WebViewClass.Please check this : https://developer.android.com/guide/webapps/webview.html#NavigatingHistory

How to get Action from Webview android

How to handle View in Webview(Android). example - i am loading some web page which has some Text Field and buttons. From application level how to find whether text filed is clicked or button is clicked.
Set WebViewClient on your webView .Read here

How to avoid click on lower html element when clicking on the html element above it on touch devices?

I am making cross-platform mobile site using html and jQuery for android, windows and iPhone devices .
The problem Is when I click on an element which is above another element then the click event is also triggered on below element.
I am having a custom popup which opens on center of page and having a button exactly below the button there is also a button on page with click event.
So on clicking the button on popup the event is also fired on button below the popup.
How to prevent this kind of events on Touch devices.
Same is the case with the drop-down when I select or click the option then the below button's click event get fired up.
you should use event.stoppropagation():
$('your-element').on('click', function(e){
e.stopPropagation();
// other stuff here
})
That should solve your problem.

android pass onClick event to child

I have a button and as a background, I have an image selector which reacts on press event. The button's text is a spannable string which may contain some links or phone numbers. I linkify those links and phone numbers but how to pass further onClick event to button's text to open browser when I tap over a link?
The button is not designed to work that way. I would use a text view and manipulate background, so when the user cliks on the link the background changes and with some delay changes back and only then open the web link.

Categories

Resources