Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't select option in android webview

Android's WebView is correctly displaying the option items, but when I try to select one of them, the dropdown popup closes, the default selection keeps showing up and the dropdown menu freezes which means another click doesn't display the selection popup again.

This misbehavoir occures, as far I could test it, only on emulators and the HTC One. I've test it on devices like: HTC Disire , HTC Disire HD, Samsung Galaxy GT-I5500 and Samsung S3 where everythings works just fine.

It seems like the HTC One doesn't support select / option element used in a WebView.

It doesn't make difference if I load the content via local loadData or loadUrl from a website.

content:

<body>
    <select >
        <option value='option1'>option1</option>
        <option value='option2'>option2</option>
    </select>
</body>

Anyone with the same experiences and solutions?

like image 834
casaflowa Avatar asked Nov 01 '22 15:11

casaflowa


1 Answers

I had a similar issue. the WebView did not open the context menu on clicking the:

 <option value='op1'>first</option>
 <option value='op2'>second</option>

in the html page.

The problem was that the context of the WebView wasn't the same as the current Activity where the WebView was displayed.

My solution was to use MutableContextWraper and chage the base context to be the current Activity.

like image 91
Yosef Avatar answered Nov 12 '22 10:11

Yosef