Android Question View Products from Database (jRDC2)

Hi,

What could be the problem in this code that I created, supposedly when I click an item in the List View the Product Name, Price and Images will be displayed to the next activity which I named ViewProduct. The Data that is displayed in the list view is from the database(phpMyAdmin).

Thanks a lot.

View:
#Region  Activity Attributes
    #FullScreen: True
    #IncludeTitle: False
#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 Drawer As B4XDrawer
    
    Private lblDrawerADT As Label
    Private LabelProductName As Label
    Private LabelPrice As Label
    Private ButtonAddtoCart As Button
    Private ImageViewAddToCart As ImageView
    Private EditTextQuantity As EditText
End Sub

Sub Activity_KeyPress (KeyCode As Int) As Boolean 'Return True to consume the event
    If KeyCode = KeyCodes.KEYCODE_BACK And Drawer.LeftOpen Then
        Drawer.LeftOpen = False
        Return True
    Else
        StartActivity(Homepage)
        Activity.Finish
    End If
    Return False
    

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("Layout1")
    Activity.LoadLayout("AddtoCart")
    
    
    Drawer.Initialize(Me, "", Activity, 300dip)
    Drawer.CenterPanel.LoadLayout("AddtoCart")
    Drawer.LeftPanel.LoadLayout("Drawer")
    GetSelectedGulay(Homepage.item_name)
    
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub




Sub lblDrawerADT_Click
    Drawer.LeftOpen = True
End Sub

Sub CreateRequest As DBRequestManager
    Dim req As DBRequestManager
    req.Initialize(Me, Main.exportrdcLink)
    Return req
End Sub

Sub CreateCommand(Name As String, Parameters() As Object) As DBCommand
    Dim cmd As DBCommand
    cmd.Initialize
    cmd.Name = Name
    If Parameters <> Null Then cmd.Parameters = Parameters
    Return cmd
End Sub

Sub GetSelectedGulay(prodname As String)
    Dim req As DBRequestManager = CreateRequest
    Dim cmd As DBCommand = CreateCommand("selectedGulay", Array(prodname))
    Wait For (req.ExecuteQuery(cmd, 0, Null)) JobDone(j As HttpJob)
'    ProgressDialogShow("Loading...")
    If j.Success Then
        req.HandleJobAsync(j, "req")
        Wait For (req) req_Result(res As DBResult)
        'work with result
        'req.PrintTable(res)
        Log(res.Columns)
        For Each row() As Object In res.Rows
            Dim oBitMap As Bitmap
            Dim buffer() As Byte
        
            buffer = row(res.Columns.Get("Image"))
            oBitMap = req.BytesToImage(buffer)
            
            LabelProductName.Text = row(0) & row(3)
            LabelPrice.Text = "P" & row(1) & "/kilo"
            ImageViewAddToCart.Bitmap = oBitMap
        Next
    
    Else
        Log("ERROR: " & j.ErrorMessage)
    End If
'    ProgressDialogHide
    j.Release
End Sub

Sub ButtonAddtoCart_Click
    
End Sub
 

Attachments

  • ViewProduct.zip
    16.9 KB · Views: 219
Top