美文网首页
FusionApp小技巧(网上收集整合)

FusionApp小技巧(网上收集整合)

作者: lfpwhy | 来源:发表于2018-10-09 12:45 被阅读0次

常用代码

//网页即将加载
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.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
}

网页顶栏及头部空白物理遮盖

javascript:
if(document.getElementsByTagName('BODY')[0].scrollTop<46){
      document.getElementsByTagName('BODY')[0].scrollTop=46;
    } else {
      return false;
    }

浮动广告查杀脚本

var d=document;var s=d.createElement('script');s.setAttribute('src', 'https://greasyfork.org/scripts/7410-jskillad/code/jsKillAD.user.js');d.head.appendChild(s);

清除缓存

第一部分

//自定义事件 > 程序启动
function clr()  
  import "java.io.File" 
  items={"浏览记录","缓存文件"}
  多选对话框=AlertDialog.Builder(this)
  .setTitle("清除记录")  
  .setPositiveButton("确定",function()
    if clearhistory==1 and clearall==1 then
      File(lstads).delete()
      File(lstwebads).delete()
      lst={}
      lstweb={}
      os.execute("pm clear "..activity.getPackageName())
    elseif clearhistory==0 and clearall==1 then
      os.execute("pm clear "..activity.getPackageName())
    elseif clearhistory==1 and clearall==0 then
      File(lstads).delete()
      File(lstwebads).delete()
      lst={}
      lstweb={}
    else return nil
    end
  end)
  .setMultiChoiceItems(items, nil,{ onClick=function(v,p)     
      if p==0 then clearhistory=1
      end    
      if p==1 then clearall=1
      end
    end})
  多选对话框.show();
  clearhistory=0
  clearall=0
end

第二部分 填入点击事件

clr()

相关文章

  • FusionApp小技巧(网上收集整合)

    常用代码 网页顶栏及头部空白物理遮盖 浮动广告查杀脚本 清除缓存 第一部分 第二部分 填入点击事件

  • 网上开店小技巧

    下面我为大家分享网络赚钱的小窍门,网络迅速的发展,带动了经济的发展,从整体的角度来看网络可以影响着赚钱的欲望! 很...

  • 理财|逐步走理财-4

    这篇文章作为一个整合,收集简书平台和网上理财小伙伴的心得,作为学习资料的整合。 理财配置 实际配置案例 固定收益类...

  • 2-cookies和session(个人附加token)

    本文基本是从网上收集整合修改而成的,并非本人原创。主要是这个http://www.cnblogs.com/andy...

  • 开发小技巧收集

    IOS 控件 - UIButton 文字靠左想要设置 uibutton 的文字的位置的时候,不能使用btn.tit...

  • 开发小技巧收集

    linux服务器rz命令上传文件

  • Pytorch小技巧收集

    小技巧记录一 导语:批数据,矩阵相乘,处理过程假设:0.self.L=(1000,300) 注:Em...

  • 干货 | 兼职小窍门

    随着兼职大军的不断壮大,网上的相关指南、技巧等也铺天盖地,让人看着都眼花。今天,小编就整合了一些兼职小窍门分享给大...

  • 社群运营小技巧收集

    1,在一个社群活动的时候,需要提前联系好当事人,确认每个当事人的时间!为了确保活动的效果还需要做一些1对1私聊的动...

  • css小技巧整理收集

    文字超出显示省略号 或者

网友评论

    本文标题:FusionApp小技巧(网上收集整合)

    本文链接:https://www.haomeiwen.com/subject/dmyeaftx.html