I tried all sort of combination for android and it doesnt work. Following is my full code. I just copied main part that is related and added a comment “This doesnt work.”
-- Project: StructuralCompass -- File name: main.lua -- -- Author: Amir Farazmand -- Supports Graphics 2.0 --------------------------------------------------------------------------------------- local widget = require( "widget" ) local lfs = require( "lfs" ) function projectnamefield( event ) if ( "began" == event.phase ) then textMode = true elseif ( "ended" == event.phase ) then -- This event is called when the user stops editing a field: for example, when they touch a different field textField.isVisible = false tableView.isVisible = true local filePath = system.pathForFile( textField.text, system.DocumentsDirectory ) file = io.open( filePath, "a" ) io.close( file ) listFile() elseif ( "submitted" == event.phase ) then -- This event occurs when the user presses the "return" key (if available) on the onscreen keyboard tableView.isVisible = true -- Hide keyboard native.setKeyboardFocus( nil ) textMode = false textField.isVisible = false local filePath = system.pathForFile( textField.text, system.DocumentsDirectory ) file = io.open( filePath, "a" ) io.close( file ) listFile() end end ------------File list local function mainMenu( ) function listFile( ) fileNo=0 fileName = {} \_W=320 \_H=480 local doc\_path = system.pathForFile( "", system.DocumentsDirectory ) for file in lfs.dir(doc\_path) do fileNo = fileNo+1 fileName[fileNo]=file end if fileNo \<3 then fileNo=3 end -- No file recorded yet function delProject( event ) if event.action == "clicked" then print ("yes") end local alert = native.showAlert( selectedFile, "Due to Android limitation deleting files individually is not possible. You can delete all your projects from the Android App Settings.", { "Ok" } ) filePath = system.pathForFile( selectedFile, system.DocumentsDirectory ) os.remove( filePath ) -- This doesnt work. listFile() end local function onRowRender( event ) -- Get reference to the row group local row = event.row -- Cache the row "contentWidth" and "contentHeight" because the row bounds can change as children objects are added local rowHeight = row.contentHeight local rowWidth = row.contentWidth if jobText then jobText =nil end local jobText = display.newText( row, row.id, 0, 0, systemFontBold, \_W\*.04 ) jobText:setFillColor( 0,0,0 ) jobText.anchorX = 0 jobText.x = \_W\*.08 jobText.y = rowHeight \* 0.55 -- Precalculate y position. NOTE: row's height will change as we add children --local rowArrow = display.newImage( row, "rowArrow.png", false ) -- Right-align the arrow --rowArrow.anchorX = 1 --rowArrow.x = rowWidth - \_W/6 --rowArrow.y = rowHeight\*.5 end local function onRowTouch( event) local function projectOption( event ) if event.action == "clicked" then local i = event.index if i == 1 then local alert = native.showAlert( "ALERT", "Are you sure to delete this file? "..selectedFile, { "Yes", "No" }, delProject ) elseif i == 3 then startRecording() tableView.isVisible=false end end end selectedFile = event.row.id if selectedFile == "Create a New Project or Open existing below" then tableView.isVisible=false local tHeight = 35 if isAndroid then tHeight = 35 end -- adjust for Android textField = native.newTextField( 155, 20, 280, tHeight ) textField.text = "EnterProjectName" textField:addEventListener( "userInput", projectnamefield ) else local alert = native.showAlert( "Project", "What to do with this file? "..selectedFile, { "Delete Project", "Cancel", "Open" }, projectOption ) end end -- Create the file List tableView = widget.newTableView { left = 0, top = 0, height = 330, width = 300, onRowRender = onRowRender, onRowTouch = onRowTouch, listener = scrollListener } -- Insert 40 rows for i = 1, fileNo-2 do -- Insert a row into the tableView if i==1 then tableView:insertRow{id = "Create a New Project or Open existing below"} end tableView:insertRow{id = fileName[i+2]} end end-- end of listFile listFile() end --end of main menu timer.performWithDelay( 500, mainMenu )