我想从文件读入文本框,用户可以在其中添加更多数据,然后它将以短信形式发送
我怎样才能做到这一点
我尝试了一些现成的代码,但总是不工作
enter code here
-------------------------------------------------- -------------------------------------------
--scence4-1.lua
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
local widget = require( "widget" )
---------------------------------------------------------------------------------
-- 开始实施
local obj2 = display.newImage( "images/bg4-1.png")
local btn1 = display.newImage( "images/btn_send.png",151,415 )
本地 btn2 = display.newImage( "images/btn_cancel.png",6,415 ) btn1.id = "发送对象"
本地 myname = GV_Name 本地 myid = GV_ID_NO
print (myname)
print(myid)
function scene:enterScene( event )
local params = event.params
print (params.GV_Name)
print (params.GV_ID_NO)
end
local path = system.pathForFile( "data.txt", system.DocumentsDirectory )
local fh_note = io.open( path, "r" )
if fh_note then
print (path)
io.close( fh_note )
end
textBox = native.newTextBox(25, 95, 265, 305 )
print(textBox.text)
textBox:setReferencePoint(display.TopCenterReferencePoint)
--textBox.x = screenCenter
textBox.size = 16
textBox.isEditable = true
local my_text = textBox.text
-- onRelease listener for 'sendSMS' button
local function onSendSMS( event )
-- compose an SMS message (doesn't support attachments)
local options =
{
to = { "0505930118", "9876543210" },
body = my_text
}
native.showPopup("sms", options)
-- NOTE: options table (and all child properties) are optional
end
local function onbtn1Touch( event )
if event.phase == "began" then
print (my_text)
print( "Touch event began on: " .. event.target.id )
--onRelease = onSendSMS
end
return true
end
btn1:addEventListener( "touch", onSendSMS )``
return scene
enter code here