Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android webview dropdown menu does not work on Android 4.x devices

Tags:

I have a problem with one of my WebView on Android 4.x devices.

Android app has a Tabhost which contains Fragments. One of the fragments contains a webview. The displayed page has a dropdown menu like this:

<select id="mySelect" name="mySelect">
    <option value="1">Testname 1</option>
    <option value="2">Testname 2</option>
    <option value="3">Testname 3</option>
</select>

Now when I open my app with a Galaxy S3 with Android 4.1.1 (or any other Android device I could get my hands on) I can select "Testname 1", then "Testname 2" and so on.

On the Galaxy Nexus (confirmed on different devices running Android 4.1.1, 4.1.2 and 4.2) when I try to select something the UI just blocks. After I switch to another tab and back to the webview tab suddenly the UI finally changes to the previously selected item.

Any idea what is causing this or how I can fix this for the Galaxy Nexus?

Important update: I could track this down to the Tabhost. When the webview is in the tabhost it does not work, when it is not it works. This might be related to this issue.

like image 793
Tim Avatar asked Nov 19 '12 13:11

Tim


People also ask

What is the Android equivalent of a dropdown menu?

In Android, Spinner is used to select one value from a set of values. In the default state, a spinner shows its currently selected value. Touching the spinner displays a drop down menu with all other available values, from which the user can select a new one. Android spinner is associated with AdapterView .

What can I use instead of WebView?

Alternatives to WebView If you want to send users to a mobile site, build a progressive web app (PWA). If you want to display third-party web content, send an intent to installed web browsers. If you want to avoid leaving your app to open the browser, or if you want to customize the browser's UI, use Custom Tabs.

Is WebView deprecated in Android?

This interface was deprecated in API level 12. This interface is now obsolete.

What is the WebView layout on Android?

The WebView class is an extension of Android's View class that allows you to display web pages as a part of your activity layout. It does not include any features of a fully developed web browser, such as navigation controls or an address bar. All that WebView does, by default, is show a web page.


1 Answers

You can actually do more with ActionBar than you can with just a TabHost. Including Tabs. link will allow you to implement the ActionBar in older versions minSdk = 4. A majority of the User Experience developers I have worked with think that Tabs are kind of passe although the do provide a familiar UI to users, but who am I to blow against the wind? The ActionBar provides a very Android specific look and clean feel to the UI. link is the documentation on Google's recommended UI patterns from that conference. link is the YouTube video discussing the UI patterns from the conference. Following these recommendations can provide a better review of your application and more sophisticated UI look for it. I am not sure what your needs are but if you are going to do something, might as well do it right? If you need some more help please let me know. I can get you examples on using the ActionBar. ActionBar link can give you some better reasons that I can why it is a good choice for the UI.

Are you implementing your Fragments correctly? link is the documentation on using them. If you are using dynamic fragments instead of fixed fragments implemented in the layout one trick that I found when writing across applications is to call the .clearBackStack(); when I am having funny issues and it seems to fix a lot of problems.

like image 111
Sean Avatar answered Oct 26 '22 19:10

Sean