Android Question using date input mask

Makumbi

Well-Known Member
Licensed User
iam trying to use this code for date input mask please help me out this is the error i get
B4X:
Logger connected to: emulator-5554
--------- beginning of main
--------- beginning of system
*** Service (starter) Create ***
** Service (starter) Start **
** Activity (main) Create, isFirst = true **
** Activity (main) Resume **
ExecuteHtml: SELECT DISTINCT Names,Class || Stream As CS,Amount As Balance FROM Balances
** Activity (main) Pause, UserClosed = false **
** Activity (accountstatement) Create, isFirst = true **
Error occurred on line: 147 (Accountstatement)
java.lang.RuntimeException: java.lang.RuntimeException: Cannot convert: class anywheresoftware.b4a.objects.EditTextWrapper, to: class flm.b4a.maskededittext.MaskedEditTextWrapper
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:170)
    at anywheresoftware.b4a.objects.ActivityWrapper.LoadLayout(ActivityWrapper.java:209)
    at de.amberhome.slidemenuexample.accountstatement._activity_create(accountstatement.java:366)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:733)
    at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:355)
    at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:255)
    at java.lang.reflect.Method.invoke(Native Method)
    at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:144)
    at de.amberhome.slidemenuexample.accountstatement.afterFirstLayout(accountstatement.java:104)
    at de.amberhome.slidemenuexample.accountstatement.access$000(accountstatement.java:17)
    at de.amberhome.slidemenuexample.accountstatement$WaitForLayout.run(accountstatement.java:82)
    at android.os.Handler.handleCallback(Handler.java:751)
    at android.os.Handler.dispatchMessage(Handler.java:95)
    at android.os.Looper.loop(Looper.java:154)
    at android.app.ActivityThread.main(ActivityThread.java:6077)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
Caused by: java.lang.RuntimeException: Cannot convert: class anywheresoftware.b4a.objects.EditTextWrapper, to: class flm.b4a.maskededittext.MaskedEditTextWrapper
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:410)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayoutHelper(LayoutBuilder.java:454)
    at anywheresoftware.b4a.keywords.LayoutBuilder.loadLayout(LayoutBuilder.java:148)
    ... 18 more
** Activity (accountstatement) Resume **

B4X:
#Region  Activity Attributes
    #FullScreen: False
    #IncludeTitle: True
#End Region

Sub Process_Globals
    'These global variables will be declared once when the application starts.
    'These variables can be accessed from all modules.

End Sub

Sub Globals
    'These global variables will be redeclared each time the activity is created.
    'These variables can only be accessed from this module.
    Private wbvTable As WebView
    'Private lblSelectedItem As Label
    Dim Froms As MaskedEditText
    'Dim From As EditText
    'Dim To As EditText
    Private 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;}"
    'Dim froms As MaskedEditText
    'Dim sendtt As Button
End Sub

Sub ShowTable
    'Dim SQLQry As String = "DELETE FROM Balances"
    'Starter.SQL1.ExecNonQuery(SQLQry)
    Private Query As String
    Query = "SELECT DISTINCT Names,Class || Stream As CS,Amount As Balance FROM Balances"
    'depending if the filter is active or not we add the filter query at the end of the query
    'the filter query is defined in the Filter Activity
    If Starter.flagFilterActive = False Then
        'btnFilter.Initialize("Filter")
        'btnFilter.Text = "Filter"    'change the text in the Filter button
    Else
        Query = Query & Starter.FilterQuery
        'btnFilter.Text = "UnFilter"    'change the text in the Filter button
    End If
    'displays the database in a table
    wbvTable.LoadHtml(ExecuteHtml(Starter.SQL1, Query, Null, 0, True))
    ReadDataBaseIDs
End Sub
Sub ReadDataBaseIDs
    Private Row As Int
    Private cursor1 As Cursor
   
    Starter.IDList.Initialize        'initialize the ID list

    'We read only the ID column and put them in a List
    If Starter.flagFilterActive = False Then
        cursor1 = Starter.SQL1.ExecQuery("SELECT ID FROM Balances")
    Else
        cursor1 = Starter.SQL1.ExecQuery("SELECT ID FROM Balances" & Starter.FilterQuery)
    End If
   
    If cursor1.RowCount > 0 Then                        'check if entries exist
        Starter.RowNumber = cursor1.RowCount                    'set the row count variable
        Starter.IDList.Initialize                                            'initialize the ID list
        For Row = 0 To  Starter.RowNumber - 1
            cursor1.Position = Row                            'set the Cursor to each row
            Starter.IDList.Add(cursor1.GetInt("ID"))        'add the ID's to the ID list
        Next
        Starter.CurrentIndex = 0                                            'set the current index to 0
    Else
        Starter.CurrentIndex = -1                                            'set the current index to -1, no selected item
        ToastMessageShow("No items found", False)
    End If
    cursor1.Close                                                        'close the cursor, we don't need it anymore
End Sub

Sub wbvTable_OverrideUrl (Url As String) As Boolean
    'parse the row and column numbers from the URL
    Private values() As String
    values = Regex.Split("[.]", Url.SubString(7))
    Private row As Int
    row = values(1)
    Starter.CurrentIndex = row
    UpdateSelectedItem
   
    Return True 'Don't try to navigate to this URL
End Sub

Sub UpdateSelectedItem
    Private Query As String
    Private Curs As Cursor
   
    Query = "SELECT DISTINCT Names, Class,Stream,Amount FROM Balances WHERE ID = " & Starter.IDList.Get(Starter.CurrentIndex)
    Curs = Starter.SQL1.ExecQuery(Query)
    Curs.Position = 0
    'lblSelectedItem.Text = Curs.GetString("Names") & " " & Curs.GetString("Class")& " " & Curs.GetString("Amount")
    'Accounts.Text = Curs.GetString("Names")
    Curs.Close
End Sub
Sub ExecuteHtml(SQL As SQL, Query As String, StringArgs() As String, Limit As Int, Clickable As Boolean) As String
    Private 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
    Private 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
   
    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>")
                sb.Append(".stub'>").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
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Activity.LoadLayout("accountstatement")
    Activity.Title="Provisional Statement"
    Froms.Initialize("Froms")
    Froms.Format= "Date/time: ##/##/####"
    Froms.InputType = Froms.INPUT_TYPE_NUMBERS
    'froms.Initialize("froms")
    'froms.Format = "Date/time: ##/##/####"
    'froms.InputType = froms.INPUT_TYPE_NUMBERS
    'froms.SingleLine = True
'    Activity.AddView(froms, 0, 0, 320dip, 50dip)
   
    'sendtt.Initialize("sendtt")
    'froms.SingleLine = True
    'Activity.AddView(sendtt, 0, 0, 320dip, 50dip)
    ShowTable
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub


Sub Button1_Click
   
End Sub
 

Attachments

  • Screenshot_1545333731.png
    Screenshot_1545333731.png
    43.1 KB · Views: 308

Makumbi

Well-Known Member
Licensed User
Based on the error message 'Froms' is a regular EditText not a MaskedEditText. Assuming that MasedEditText is a custom view (I'm not sure) then you should delete the existing view and add it with Add View - Custom Views - MasekdEditText.
How can i add it as a custom view to the already existing layout. Because i have already put control on the layout and i have imported the mask library into my app please provide me with some details thank you
 
Upvote 0

Makumbi

Well-Known Member
Licensed User
t
1. Open your layout in designer
2. In the Visual Designer select 'Add View'
3. Click 'Customview'
4. Click 'MaskedEditText'
Thanks You Mahares please help me out again i also wanted to know whether it is possible to integrate crystal reports into my b4a app
 
Upvote 0

mangojack

Expert
Licensed User
Longtime User
New Question = New Thread
 
Upvote 0
Top