jQuery Flot charting library in Android WebView doesn't work correctly

I'm trying to implement Flot charts in my Android app using WebView. Basically I have a Fragment which contains a WebView. I also have a refresh button which refreshes the Fragment (and the WebView thus) by retrieving new data from a web service and putting them in the chart.

The problem I'm having is that the WebView at first launch (when the fragment is created) either doesn't show the chart or it shows a smaller chart (i.e. half screen). When I click refresh the chart shows fine without any problem, so the problem is only when the fragment is first created.

What I do on onCreateView is calling this:


And I have an AsyncTask which retrieves the data from the server, and then calls javascript on the WebView like this:

chartWebView.loadUrl("javascript:displayChart(" + data + ")");

I also have overrided the onResume method where I call the refresh() function.

The refresh() method basically executes the AsyncTask to reload the data, which at onPostExecute(...) calls the javascript on the WebView.

Any hints?


Just a guess but...

webView.loadUrl() is asynchronous. I think your first AsyncTask executes before the loadUrl completes. I'd recommend to do your initial displayChart in an onPageFinished.

Need Your Help

Spring 3.0 and EJB3 integration

spring ejb-3.0

I am trying to integrate EJB3 and Spring. I am using Jboss 5. The following is my ejb bean class

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.