contenido1 = <!DOCTYPE html><html> <head><meta charset="utf-8"> <script language="JavaScript">
patron2 = function AAA(elemento) { window.AppInventor.setWebViewString("AAA"); }
contenido3 = </script></head> <body>
patron4 = <input name="AAA" type="button" value="BBB" onClick="AAA(this);" /><br><br>
contenido5 = </body></html>
then replace AAA and BBB by name and text button.
Regards.
http://kio4.com/appinventor/169CCC_javascript_botones_codigo.htm