Android Question I want a code that copies the text in WebView1 To EditText1

josejad

Expert
Licensed User
Longtime User
Search the forum for WebViewExtras.

You can get some inspiration from:

B4X:
Sub Button1_Click
    Dim Javascript As String
    Javascript="B4A.CallSub('GetBase30', true, SendBase30())"
    WebViewExtras1.ExecuteJavascript(Javascript)
End Sub

Sub GetBase30(data As String)
    Label1.Text = data
End Sub
 
Upvote 0

alfaiz678

Active Member
Licensed User
Search the forum for WebViewExtras.

You can get some inspiration from:

B4X:
Sub Button1_Click
    Dim Javascript As String
    Javascript="B4A.CallSub('GetBase30', true, SendBase30())"
    WebViewExtras1.ExecuteJavascript(Javascript)
End Sub

Sub GetBase30(data As String)
    Label1.Text = data
End Sub

I could not apply it
Is there an explanation?
 
Upvote 0

josejad

Expert
Licensed User
Longtime User
I could not apply it
What error do you get?

You should have a javascript function in your webpage code, something like:
B4X:
function GetEditText() {
    return document.getElementById('YourEditTextIDHere').value;   
}

And in your app something like:
B4X:
Sub Button1_Click
    Dim Javascript As String 
    Javascript="B4A.CallSub('SetTextLabel', true, GetEditText())" 'First parameter, a sub in your app, third parameter, sub you want to call in your php (or whaterver) script
    WebViewExtras1.ExecuteJavascript(Javascript)
End Sub

Sub SetTextLabel(data As String)
    Label1.Text = data
End Sub

Post the errors you get or export your project as zip and upload to the forum
 
Upvote 0

drgottjr

Expert
Licensed User
Longtime User
if all you want is a webpage as is, you don't need a webview. just download the page and assign the downloaded text to your edittext:
B4X:
    Dim wjob As HttpJob
    wjob.Initialize("",Me)
    wjob.Download("https://www.google.com")
    Wait For (wjob) JobDone(wjob As HttpJob)
    If wjob.Success Then
       edittext1.text = wjob.GetString
       wjob.Release
    else
       log("download failed: " & wjob.ErrorMessage)
    end if

otherwise, you will need to get the javascript stuff mentioned above working
 
Upvote 0

alfaiz678

Active Member
Licensed User
if all you want is a webpage as is, you don't need a webview. just download the page and assign the downloaded text to your edittext:

What I do exactly
Articles from sqlite database is displayed
Html encoding ready
It is displayed on WebView1
Because of the flexibility to specify text and text and paste for any part of the text in this tool
It has better display features than edittext1
Thank you, I will try to do it
 
Upvote 0
Top