2014年8月6日星期三
Android的WebView 注意事項
Android的WebView api是一個顯示網頁的View. 通過使用WebView, 您可以把網絡瀏覽器顯示在您的Android app上.
而 WebView 看起來可以讓我們使用很方便的方法寫出手機 APP ,可是他有幾個限制存在
1. 利用 WebView 無法直接操控手機的硬體,例如相機、重力加速度感應器、定位系統等等
2. 在 Android 當中,單純使用 WebView 寫 APP 時,如果使用者按 Back 鈕,那會直接離開應用程式,而不是回前一頁.
測試過後發現的確有許多 JavaScript 在 WebView 中是沒任何反應的,
若你希望能透過網頁做更多的事,官方文件建議調用一個瀏灠器是不錯方法,
在 Android Developers 中有提到
If your goal is only to display some HTML as a part of your UI, this is probably fine,... If you actually want a full-blown web browser, then you probably want to invoke the Browser application with a URL Intent rather than show it with a WebView.
以下是個簡單的範例在 Activity 中嵌入滿版的 WebView ,
並且檢查當用戶點選了 http://xxx/ooo.mp4 之類的連結時調用瀏灠器處理此類 URL 並結束自己
-END-
jquery 一些小細節
以下兩行都是將dialog的title移除.
$(".ui-dialog-titlebar").hide();
$("#myDialogId").siblings('div.ui-dialog-titlebar').remove();
這兩行的差異在於: 同一個網頁,如果有兩個以上的dialog,第一種寫法會影響所有的dialog;第二種寫法,只會影響指定id的dialog.
$(".ui-dialog-titlebar").hide();
$("#myDialogId").siblings('div.ui-dialog-titlebar').remove();
這兩行的差異在於: 同一個網頁,如果有兩個以上的dialog,第一種寫法會影響所有的dialog;第二種寫法,只會影響指定id的dialog.
-END-
訂閱:
留言 (Atom)