宣告:文章來源于網路,如有侵權,請聯系洗掉
網頁即將加載
--網頁即將加載
if(網頁鏈接:find"url/.")then
停止加載()
進入子頁面("游覽",{鏈接=網頁鏈接})
end
加載本地網頁
加載本地網頁("file:///android_asset/drawable/index.html")
如何呼叫瀏覽器打開當前頁面?
import "android.content.Intent"
import "android.net.Uri"
url="https://www.lanzous.com/b251218"
viewIntent = Intent("android.intent.action.VIEW",Uri.parse(url))
activity.startActivity(viewIntent)
瀏覽器打開鏈接
webView.loadUrl("https://www.baidu.com")
收到新標題
設定頂欄標題(webView.title)
專案點擊事件
進入子頁面("子頁面名",{鏈接="url",標題="標題名"})
進入子頁面("子頁面名")
去頭部留白
document.body.style.paddingTop=0
顯示或隱藏懸浮按鈕
--顯示懸浮按鈕
fltBtn.setVisibility(View.VISIBLE)
--隱藏懸浮按鈕
fltBtn.setVisibility(View.GONE)
-- 注:fltBtn為懸浮按鈕的ID,不需要更改,
懸浮點擊事件
加載Js([[document.getElementsByClassName("apk_topbar_btn")[0].parentElement.onclick()]])
懸浮選擇點擊事件
pop=PopupMenu(activity,fltBtn)
menu=pop.Menu
menu.add("選項一").onMenuItemClick=function(a)
進入子頁面("子頁面名",{鏈接="url1"..webView.getUrl()})
end
menu.add("選項二").onMenuItemClick=function(a)
進入子頁面("子頁面名",{鏈接="url2"..webView.getUrl()})
end
pop.show()
設定螢屏方向
import "android.content.pm.ActivityInfo"
activity.setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_SENSOR);
視頻決議播放
加載網頁("vip決議url"..webView.getUrl());
橫屏或豎屏
-- 橫屏
activity.setRequestedOrientation(0);
--豎屏
activity.setRequestedOrientation(1);
各控制元件ID
searchEdtTxt -- 搜索欄
toolbar.parent -- 頂欄
toolbar -- 標題欄
titleTvw -- 頂欄標題
webView -- 瀏覽器
fltBtn -- 懸浮按鈕
pager -- 滑動表單
popmenu_position -- 選單欄
sidebar -- 側滑欄顯示圖示
pgsBar -- 進度條
sideLvw -- 側滑圖示
menu_button -- 選單圖示
menuBtn -- 側滑欄圖示
開啟和關閉側滑
--打開側滑
drawerLayout.openDrawer(3)
--關閉側滑
drawerLayout.closeDrawer(3)
均放在點擊事件
--自定義底欄點擊事件
index=1--底欄專案序號
bmBarLin.getChildAt(index-1).onClick=function()
--點擊事件
end
--自定義標簽欄點擊事件
local index=1--標簽欄專案序號
tabBar.getChildAt(index-1).onClick=function()
--點擊事件
end
多頁面搜索
-- By: QQ3
local urls={"https://www.google.com/search?q=%s","https://m.baidu.com/s?wd=%s","https://m.so.com/s?q=%s","http://cn.bing.com/search?q=%s","http://m.chinaso.com/page/search.htm?keys=%s","https://m.sogou.com/web/searchList.jsp?keyword=%s","https://m.sm.cn/s?q=%s"}
searchEdtTxt.setOnEditorActionListener{
onEditorAction=function(view,action,event)
local text=tostring(view.text)
if text~=nil and text~="" then
searchEdtTxt.setHint(text)
local URLEncodeer=import"java.net.URLEncoder"
for index in pairs(urls) do
if allWebView[index] and urls[index]~=nil and urls[index]~="" then
local url=tostring(urls[index]):format(URLEncoder.encode(text))
if pager.getCurrentItem()+1==index then
task(100,function()allWebView[index].loadUrl(url)end)--解決當前頁面無法加載(與默認搜索事件沖突被覆寫)的問題
else
allWebView[index].loadUrl(url)
end
end
end
else
SearchEdtTxt.setHint("")
end
end
}
本文由【產品經理不是經理】gzh同步發布,歡迎關注
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/543612.html
標籤:其他
下一篇:Java執行緒中斷
