Hopefully I can demonstrate this so that it will be easy to understand. I want to place my manual in an activity so that the user can read it within the application. I included the file (let's call it "manual.txt") under 'Files' in the IDE so that it can be referenced under 'dirassets' when compiled. I pick the file from a dialog or reference it directly. Here is the code:
This works fine in the 'Main' activity but there really isn't room for a large text box to contain the manual (it's pretty long) and I don't want to use a panel. Therefore, I thought I could put it in an activity called 'manual' and show it there where I have a large text box and an 'Open' button. Declarations, etc. are in order. Here is the code for that:
I also tried it like this:
It does not work when I take it out of the main module. In fact I am unable to get the file dialog to show. I have tried it in various ways ( without the file dialog and referencing the file directly) but just can't do it in any place except the main module. Incidentally, I really like the file dialog agraham made. I will use it elsewhere even if I can't get this to work. I'm sure I am missing some logic here but can't see it. Surely I should be able to display a text file (could I also use a 'doc or 'pdf'?)
As always, I appeciate your time, patience and expertise.
Jim
B4X:
Sub Activity_Create(FirstTime As Boolean)
activity.LoadLayout ("start")
txtfilename.RequestFocus
File.Copy (File.DirAssets ,"manual.txt",File.DirInternal ,"manual.txt")
End Sub
Sub btnFile_Click
Dim text As String
Dim fd As FileDialog
Dim bmp As Bitmap
fd.FastScroll = True
fd.FilePath=File.DirInternal
fd.FileFilter = ".txt"
ret = fd.Show("B4A File Dialog", "Select", "Cancel", "", Null)
text=File.ReadString(File.DirInternal ,fd.ChosenName )
txtmanual.text=text
End Sub
This works fine in the 'Main' activity but there really isn't room for a large text box to contain the manual (it's pretty long) and I don't want to use a panel. Therefore, I thought I could put it in an activity called 'manual' and show it there where I have a large text box and an 'Open' button. Declarations, etc. are in order. Here is the code for that:
B4X:
Sub btnOpen_cilck
Dim fd As FileDialog
Dim bmp As Bitmap
fd.FastScroll = True
fd.FilePath=File.DirInternal
fd.FileFilter = ".txt"
ret = fd.Show("B4A File Dialog", "Select", "Cancel", "", Null)
text=File.ReadString (File.DirInternal ,fd.ChosenName )
txtmanual.text=text
End Sub
I also tried it like this:
B4X:
sub btnOpen_click
File.OpenInput (File.Dirinternal,"manual.txt")
text=File.ReadString (File.dirinternal ,"manual.txt")
txtmanual.text=text
End Sub
It does not work when I take it out of the main module. In fact I am unable to get the file dialog to show. I have tried it in various ways ( without the file dialog and referencing the file directly) but just can't do it in any place except the main module. Incidentally, I really like the file dialog agraham made. I will use it elsewhere even if I can't get this to work. I'm sure I am missing some logic here but can't see it. Surely I should be able to display a text file (could I also use a 'doc or 'pdf'?)
As always, I appeciate your time, patience and expertise.
Jim