Android Question How to create a whats up like layout

Makumbi

Well-Known Member
Licensed User
Please help i have a small database where i peak the person's name and then i send the message please help can i create a simple layout like that of whatsup were i can select from the listed names and then i send the message and at the same time view the received response.

the problem with my current layout is i have to click on sendsms to see what i has been sent and also click on received to see recieved . yet i would want to view the entire conversation in a good layout please help me out thanks

the code below reads the received messages from the table
B4X:
Sub ShowTable2
    B4XTable1.Clear
    B4XTable1.AddColumn("DateRecieved", B4XTable1.COLUMN_TYPE_TEXT)
    B4XTable1.AddColumn("Sms", B4XTable1.COLUMN_TYPE_TEXT)
    'B4XTable1.AddColumn("ID", B4XTable1.COLUMN_TYPE_TEXT)

    data.Initialize
    Dim rs As ResultSet = Starter.SQL1.ExecQuery("SELECT DISTINCT Daterecieved,Sms as RecievedMessage,ID FROM Recievedsms")
    Do While rs.NextRow
        Dim row(2) As Object
        row(0) = rs.Getstring("Daterecieved")
        row(1) = rs.GetString("RecievedMessage")
        '& " " & rs.GetString("LastName")
    '    row(2) = rs.GetString("ID")
        'Some of the fields are Null. We need to convert them to empty strings:
        'If row(2) = Null Then row(2) = ""
        'row(3) = rs.GetString("RecievedMessage")
        data.Add(row)
    Loop
    rs.Close
    B4XTable1.SetData(data)
  
End Sub

the code below shows sent messages
B4X:
Sub ShowTable
    If lblSelectedItem.Text="Send" Then
        'B4XTable1.Refresh
        B4XTable1.Clear
        B4XTable1.AddColumn("Datesent", B4XTable1.COLUMN_TYPE_TEXT)
        B4XTable1.AddColumn("SentMessage", B4XTable1.COLUMN_TYPE_TEXT)
    '    B4XTable1.AddColumn("ID", B4XTable1.COLUMN_TYPE_TEXT)

        data.Initialize
        Dim rs As ResultSet = Starter.SQL1.ExecQuery("SELECT DISTINCT Datesent,Sms as SentMessage,ID FROM Sentmessages")
        Do While rs.NextRow
            Dim row(2) As Object
            row(0) = rs.GetString("Datesent")
            row(1) = rs.GetString("SentMessage")
            'row(2) = rs.GetString("ID")
            Log(row(1))
            'Log(row(3))
            'Log(row(2))
            '& " " & rs.GetString("LastName")
            'row(2) = rs.GetString("ID")
            'Some of the fields are Null. We need to convert them to empty strings:
        '    If row(1) = "Null" And  row(2) = "Null" Then
                'Return
            'Else
            '    If row(1) = "Null" Then row(2) = "Null"
                'row(1) = rs.GetString("SentMessage")
      
                data.Add(row)
            'End If
      

        Loop
        rs.Close
        B4XTable1.SetData(data)
        B4XTable1.Refresh
         Return
 

Attachments

  • Screenshot_1578509840.png
    Screenshot_1578509840.png
    35.9 KB · Views: 197
  • Screenshot_1578509768.png
    Screenshot_1578509768.png
    21.8 KB · Views: 204
  • Screenshot_20200106-093136.png
    Screenshot_20200106-093136.png
    57.4 KB · Views: 200
Last edited:

Jeffrey Cameron

Well-Known Member
Licensed User
Longtime User
how can i save the chat conversation
This could be a simple as saving what you're displaying in the list to a flat text file that you write to disk on Activity_Pause and load in Activity_Resume, or as complex as a SQLite database to track the message history, that part is up to you.

I would recommend that you create a simple type that mimics your message structure and save a map of those with B4XSerializer.
 
Upvote 0
Top