for i=0,bar.getChildCount()-1do bar.getChildAt(i).getChildAt(0).getChildAt(0).textColor=0xFFFFD6E2 end bar.getChildAt(t).getChildAt(0).getChildAt(0).textColor=0xffffffff setWidth(choose.getChildAt(0),bar.getChildAt(t).width) choose.getChildAt(0).x=bar.getChildAt(t).x end, onPageScrollStateChanged=function(i) data.scrollData.scroll=i>0 end, onPageScrolled=function(a,b,c) local nowView=bar.getChildAt(a)
local nextView=bar.getChildAt(a==bar.getChildCount() and bar.getChildCount() or a+1)
if data.scrollData.scroll and b~=0then if data.scrollData.last and data.scrollData.last<b then if nextView.width<nowView.width then setWidth(choose.getChildAt(0),nowView.width-((nowView.width-nextView.width)*b)) else setWidth(choose.getChildAt(0),nowView.width+((nextView.width-nowView.width)*b)) end choose.getChildAt(0).x=nextView.x-((nextView.x-nowView.x)*(1-b)) else
local lastView=bar.getChildAt(a) local nowView=bar.getChildAt(a+1)
if lastView.width>nowView.width then setWidth(choose.getChildAt(0),nowView.width+((lastView.width-nowView.width)*(1-b))) else setWidth(choose.getChildAt(0),nowView.width-((nowView.width-lastView.width)*(1-b))) end
choose.getChildAt(0).x=lastView.x+((nowView.x-lastView.x)*b) end
end
if b==0or c==0then for i=0,bar.getChildCount()-1do bar.getChildAt(i).getChildAt(0).getChildAt(0).textColor=0xFFFFD6E2 end bar.getChildAt(pg.getCurrentItem()).getChildAt(0).getChildAt(0).textColor=0xffffffff end
--创建表 functioncreate_config() local sql="create table config(name varchar primary key NOT NULL,value varchar ,bool boolean)" ifpcall(exec,sql) then else print("创建配置表失败") end end
--示例:执行语句,拿到结果。这个语句用来统计总数。 local sql="select count(*) from sqlite_master where type='table' and name='config'" ifpcall(raw,sql,nil) then cursor.moveToFirst(); --移动指针 local result = cursor.getLong(0); if result==0then create_config() end else print("数据库查询失败!") end
--删除表记录 local sql="delete from config where name='"..record_name.."'"
--重命名表 local sql="ALTER TABLE "..old_name.." RENAME to "..new_name
--为表插入新纪录 functionaddrecord(tablename,newrecord,newremark) local newrecord=newrecord:gsub('&&',"•") --单词分词的替换 local newremark=newremark:gsub('&&',"•") local sql="insert into "..tablename.."(cyan,remark) values('"..newrecord.."','"..newremark.."')" --print(sql) ifpcall(exec,sql) then --MD提示("添加新记录成功",0xFF2196F3,0xFFFFFFFF,4,10) else print("添加新纪录失败") end end
--开启弹幕传参 functionballistic()--弹道一事件 home_view() localrandom=math.random(1,#home_list_name) --随机数取当前弹幕序列中的卡片 bullet_text.setText(random_sqlite(home_list_name[random])) --设置随机记录到Text上去 bullet_cars.measure(View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED),View.MeasureSpec.makeMeasureSpec(0,View.MeasureSpec.UNSPECIFIED)); local width =0-(bullet_cars.getMeasuredWidth()); --获取设置文字后的控件宽度。这里需注意,必须在setText下面,否则读不到正常宽度。 bullet_cars.startAnimation(TranslateAnimation(获取屏幕宽(),width,0,0).setDuration(20000).setFillAfter(true).setAnimationListener(AnimationListener{ onAnimationEnd=function()--设置补间动画结束监听 if read_config("bullet_state") == truethen ballistic() end end})) if read_config("log")==truethen locallog= "弹道1,表:"..home_list_name[random].."内容:"..random_sqlite(home_list_name[random]).."弹幕状态:"..tostring(read_config("bullet_state")) addrecord("log","弹道一",log) end end