User Tools

Site Tools


sample_code:using_app.execute

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

sample_code:using_app.execute [2015/10/30 20:46]
pedrod created
sample_code:using_app.execute [2015/10/31 04:56]
Line 1: Line 1:
-Webviews are useful where you want to format a dynamic page, for example, you retrieve some data from sqlite and want to display it in a HTML table. 
  
-If you want to embed links or buttons in the HTML, you need a way to pass data back to DS, use app.Execute 
-<code> 
-function OnStart()  
- 
- 
-    var appjs='<script src="file:///android_asset/app.js"></script>'; 
- 
-    // note the backslashes escaping the single quotes below 
-    var myjs = '<script type="text/javascript">' + 
-                ' function myboo(id){ app.Execute("b_test(\'" + id + "\')")}</script>' ; 
- 
- 
-    lay = app.CreateLayout("linear", "VCenter,FillXY");      
- 
-    web = app.CreateWebView(0.8, 0.8);    
-   
-    lay.AddChild(web);  
-    app.AddLayout(lay);  
- 
-    var b1 = "<button id= 'boo' onclick=myboo(id)>say boo</button>"; 
-    var b2 = "<button id='bah' onclick=myboo(id)>say bah</button>";  
- 
-    web.LoadHtml(appjs + myjs + b1 + b2); 
- 
-     
- 
- 
- 
-function b_test(x) { app.ShowPopup(x); }; 
-</code> 
sample_code/using_app.execute.txt · Last modified: 2015/10/31 04:56 (external edit)