Set the WebView widget
Activity will be a range variable named browser's tied to the WebView control. WebView is a very complex class, highly customizable. For example, you need to set number of classes to be associated with the web browser is expected to function. This is the programmer must invest some effort to get some useful function in the world. However, this custom is no limit. For purposes of this application, WebView control has been minimal deployment.
The function of the parameter is a Java class instance and a name space identifier. For example, for this application, you define a calc name space, and achieving a class called CalculatorHandler the code shown in Listing 5.
Listing 5. CalculatorHandler achieve
Listing 6. WebView control is rendered (and executed) index.html
Closer look at the list at the end of the button handler 6. Basically, these are called window.calc button handler method name space, these methods AndroidJSON.java the CalculatorHandler class implementation.
Should now be more in-depth look at Java code.
AndroidJSON.java Listing 7 contains the code that handles button to select.
In the Simple example, passed a string. However, when the need to address the more complex the structure of how to do it? This is where JSON can come in handy. Listing 8 shows PerformComplexCalculation () function call, the function see Listing 6.
Listing 8. By passing a JSON object to call a more complex function
* Operation - to deal with the name of the function or procedure
* Arguments - this is a integer array
For a slightly more complex example, to encourage Hello nice about Dynamic button is selected in the WebView in the code.
JSON object exchange
On this method, no particular place; it is just a collection of use data in the page-level example. Perhaps the data is stored in the database Android applications will be useful. How this data back to Java code?
To send a string to an array of objects, you call JSON.stringify function, the array is passed as a parameter. Necessary, stringify function allows customization of a complex object to be formatted a specific property. How is this done on more information, see the explanation json.org
Related Posts of Mixed JSON's Android Android application
DWR (Direct Web Remoting) is a Open source The class library that can help developers site contains AJAX technology. It can permit in the browser's code uses WEB server running on the JAVA function, just like it at the same browser. It contains t ...
Web20 are the cornerstone of AJAX, and now several online popular open source AJAX frameworks, such as: jQuery, Mootools, Dojo, Ext JS and so on, then we in the end of the circumstances under which the use of that framework? Following excerpt is a set of
Namespace (namespace): A headache for the developers is the question how to prevent function name / class name and other people's conflicts, in an internal project team can be named among the scheduled (such as additional prefix, etc.) to solve t ...
This is a very easy-to-use widget, the parameters have default values, default values, see the Notes wait = new WaitingTip(); wait.show(document.getElementById('id')); //Parameter 1 is displayed, in reference to the object ... wait.hide(); //Hide The use
Read some of the unit test article, from the article in the interception of a number of information, which could be considered in the learning process, a summary of it! See future! Unit testing code is not used to prove you are right, but in order to ...
The end of the project stage, the client suddenly put forward a very troublesome but normal demand, the system records all changes must be carried out. Formats such as: 2004.1.1 12:30 Ikuya wind orders Sales Order Date 2004.1.2-> 2004.1.3 The firs ...