za pomocą javascript w przeglądarce internetowej Android
Próbuję uruchomić działanie z interfejsu javascript w moim widoku sieci Web. Przykład pokazuje toast. Jak mogę nazwać klasę zamiast toastu?
<code>public class JavaScriptInterface { Context mContext; /** Instantiate the interface and set the context */ JavaScriptInterface(Context c) { mContext = c; } /** Show a toast from the web page */ public void showToast(String toast) { Toast.makeText(mContext, toast, Toast.LENGTH_SHORT).show(); } } </code>
to dla strony html.
<code><input type="button" value="Say hello" onClick="showAndroidToast('Hello Android!')" /> <script type="text/javascript"> function showAndroidToast(toast) { Android.showToast(toast); } </code>