Reputation: 51
I m trying to show a simple select tag in a webview
<select >
<option value = "1" selected>Value 1</option>
<option value="2">Value 2</option>
<option value="3">Value 3</option>
</select>
MainActivity.java :
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.activity_main);
webView = (WebView) findViewById(R.id.webView);
ProgressBar progressBar = (ProgressBar) findViewById(R.id.progressbar);
//WebSettings webSettings = webView.getSettings();
//webSettings.setJavaScriptEnabled(true);
// A activer pour surcharger la méthode onJsAlert
//webView.setWebChromeClient(new WebChromeClient());
//webView.setWebViewClient(new MegViewClient(this, progressBar));
// Récupération d'un instance sauvegardée
if (savedInstanceState != null)
webView.restoreState(savedInstanceState);
else {
webView.loadUrl("http://myUrl");
}
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
WebView.setWebContentsDebuggingEnabled(true);
}
}
AndroidManifest.xml
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="21" />
I tried with both webViewClient and with webchromeClient but I got the same result :
the select is visible but the list of option is empty.
if I try on a tablet with android 4.4, the select is wellformed.
Upvotes: 2
Views: 2144
Reputation: 61
I had the same problem. My workaround is to use this jquery tool (select2) to replace all selects.
<link rel="stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/select2/3.5.2/select2.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"></script>
<script src="http://cdn.jsdelivr.net/select2/3.5.2/select2.min.js"></script>
<select >
<option value = "1" selected>Value 1</option>
<option value="2">Value 2</option>
<option value="3">Value 3</option>
</select>
<script>
// replace all select inputs with select2
$("select").select2();
// remove the search tool inside select2
$(".select2-search, .select2-focusser").remove();
</script>
Upvotes: 4
Reputation: 51
It's seems to be a chromium bug : Issue 80909: HTML SELECT options dropdown appears blank in lollipop webview
Upvotes: 2