[Question] Copy and Paste & Extension

XverhelstX

Well-Known Member
Licensed User
Longtime User
Hello everyone,

I have some more questions about Basic4Android.

1) Is it possible to press a button, and then it copies the text of another label ?

for example, you touch button btnClick, then it copies the text of lblClick (lblClick.text) to a clipboard or something, and then when you are typing in an EditText box, you can paste the text of lblClick.text.

This is a very important feature I need for my app

2) Is it possible to view '.html' files in your browser?
like on your pc: you have file:/.../index.html and you can see it in your browser.

3) Can you detect files with extension?
for example, if you open *.txt* files with the file dialog, a msgbox appear with "TXT file opened and when you open *.html*files, a msgbox appear with "HTML file opened".

Those 3 are important features for my app.

Hope you can help me.

King regards,

XverhelstX


Thank you very much!

XverhelstX
 
Last edited:

Erel

B4X founder
Staff member
Licensed User
Longtime User
1. If it is in the same application then you do not need to copy the text to a clipboard.
Just fetch the text and add it to EditText.Text.
For clipboard you can use this library: http://www.b4x.com/forum/additional-libraries-official-updates/7382-clipboard-library.html#post42139
2. Yes. You can either send an intent to start the browser or you can show the html file in a WebView control. See PhoneIntents for opening the browser with a file/url.
3. Something like: If file.ToLowerCase.EndsWith(".txt") Then msgbox("Text File.", "")
 
Upvote 0

XverhelstX

Well-Known Member
Licensed User
Longtime User
Thanks a lot Erel!

I just found out n°3 though.
but I have a new problem.

So I have one save button and one load button.
when I press the Save button, then I do the following:
B4X:
DocTypeExt.Add(txtDocType.text)
File.WriteList(File.DirRootExternal, "Doc." & outcome, DocTypeExt)

So it writes from my editText box to a file "Doc.file.ext" in my SD card, but the edittext containts CRLF, so enters. then, when I press the load button:
B4X:
BodyOutcome = "Body." & outcome
List3 = File.ReadList(File.DirRootExternal, BodyOutcome)
BodyRead = List3
txtBodyDisplay.text = BodyRead

I receive the outcome, but all the CRLF/Enters, are changed with 'Comma's' "," and it starts and ends with "[" and "]" (open and closed brackets).

So I found a way by doing the .replace(",", CRLF) and then all the comma's will be changed by enters. But what then, if the editText already has comma's in the text. something like:
"I go to the market, eat a bagel and go home."

will change in:

"I go to the market
eat a bagel and go home."

I hope u understand what I mean ;D


Thanks (again),

XverhelstX

EDIT2: How should I open the file that is in the SD card then? something like:
B4X:
   Dim tit As InputStream
   tit = File.OpenInput(File.DirRootExternal,"index.html")
   StartActivity(PhoneIntents1.OpenBrowser(tit))

THANKS A LOT! ClipBoard works smooth!
 
Last edited:
Upvote 0

XverhelstX

Well-Known Member
Licensed User
Longtime User
oh, ok thanks.

is there also a way to replace multiple characters?
like .replace("[","]", crlf) or something?

and

How should I open the file that is in the SD card then? something like:
Code:
Dim tilt As InputStream
tilt = File.OpenInput(File.DirRootExternal,"index.html")
StartActivity(PhoneIntents1.OpenBrowser(tilt))

xverhelstx
 
Upvote 0
Top