Android Question Selected Row in webview

Sreenadh OG

Member
Licensed User
hi all,
I want to get selected Row From WebView, My webview contain many rows..

web..JPG
WebView Contain table with id and items..my code is...
B4X:
Dim HtmlCSS As String
    HtmlCSS = "table {width: 100%;border: 1px solid #cef;text-align: left; }" _
        & " th { font-weight: bold;    background-color: #acf;    border-bottom: 1px solid #cef; }" _
        & "td,th {    padding: 4px 5px; }" _
        & ".odd {background-color: #def; } .odd td {border-bottom: 1px solid #cef; }" _
        & "a { text-decoration:none; color: #000;}"

Sub ExecuteHtml(SQL As SQL, Query As String, StringArgs() As String, Limit As Int, Clickable As Boolean) As String
    Dim Table As List
    Dim cur As Cursor
    If StringArgs <> Null Then
        cur = SQL.ExecQuery2(Query, StringArgs)
    Else
        cur = SQL.ExecQuery(Query)
    End If
    Log("ExecuteHtml: " & Query)
    If Limit > 0 Then Limit = Min(Limit, cur.RowCount) Else Limit = cur.RowCount
    Dim sb As StringBuilder
    sb.initialize
    sb.Append("<html><body>").Append(CRLF)
    sb.Append("<style type='text/css'>").Append(HtmlCSS).Append("</style>").Append(CRLF)
    sb.Append("<table><tr>").Append(CRLF)
    For i = 0 To cur.ColumnCount - 1
        sb.Append("<th>").Append(cur.GetColumnName(i)).Append("</th>")
    Next
   
'    For i = 0 To cur.ColumnCount - 1
'        If i = 1 Then
'            sb.Append("<th style='width:200px;'>").Append(cur.GetColumnName(i)).Append("</th>")
'        Else
'            sb.Append("<th>").Append(cur.GetColumnName(i)).Append("</th>")
'        End If
'    Next
       
    sb.Append("</tr>").Append(CRLF)
    For row = 0 To Limit - 1
        cur.Position = row
        If row Mod 2 = 0 Then
            sb.Append("<tr>")
        Else
            sb.Append("<tr class='odd'>")
        End If
        For i = 0 To cur.ColumnCount - 1
            sb.Append("<td>")
            If Clickable Then
                sb.Append("<a href='http://").Append(i).Append(".")
                sb.Append(row)
                sb.Append(".com'>").Append(cur.GetString2(i)).Append("</a>")
            Else
                sb.Append(cur.GetString2(i))
            End If
            sb.Append("</td>")
        Next
        sb.Append("</tr>").Append(CRLF)
    Next
    cur.Close
    sb.Append("</table></body></html>")
    Return sb.ToString
End Sub
 
Last edited:

Reviewnow

Active Member
Licensed User
This came from one of the web view tutorials


B4X:
Sub WebView1_OverrideUrl (Url As String) As Boolean
    'parse the row and column numbers from the URL
    Dim values() As String
    values = Regex.Split("[.]", Url.SubString(7))
    Dim col, row As Int
    col = values(0)
    row = values(1)
    ToastMessageShow("User pressed on column: " & col & " and row: " & row, False)
    Return True 'Don't try to navigate to this URL
End Sub
 
Upvote 0

Sreenadh OG

Member
Licensed User
Thank You..:) , But I want to get the content of Id and Items. The above code will will give only index of particular Row and Column..Is it possible to get the content of selected row and column
 
Last edited:
Upvote 0
Top