ListView1_ItemClick select

sigster

Active Member
Licensed User
Longtime User
Hi can someone help me with this Please

I am try to get record from database when I click on listview
but I get error
String cannot be cast to eg.islenska_app.main$_farslur


B4X:
Sub ListView1_ItemClick (Position As Int, Value As Object)

    Dim Cursor As Cursor
      Dim tt As personangsmnn
      tt = Value
      

Cursor = SQL.ExecQuery("select * FROM landshluti where forrit like '" & tt.forrit & "%' order by forrit;")      
 Cursor.Position = 0
 labopid.Text = Cursor.GetString("slod")
  Cursor.Close


End Sub

Regards
Sigster
 

Attachments

  • Islenskt app.zip
    36.2 KB · Views: 244

mc73

Well-Known Member
Licensed User
Longtime User
I think that one possible way to solve this, is to replace AddTwoLinesAndBitmap in your read_to_listview_image sub, with AddTwoLinesAndBitmap2. This way, you will input in its last variable, the returning value (ie forrit) and then in the item_click event, you can query your database easily.
 
Upvote 0

sigster

Active Member
Licensed User
Longtime User
This how I read to the Listview


B4X:
Sub read_to_listview_image
 
Dim Bitmap1 As Bitmap
 Dim Cursor As Cursor

   ProgressDialogShow("Lés gagnaskrá")
     ListView1.Clear   
   '   ToastMessageShow("Skráinn er ekki til", True)

   Dim new As String
   new = ""
' 4 DESC ASC COLLATE NOCASE
            '   ProgressDialogShow("Lés gagnaskrá")
            '   DoEvents   

Cursor = SQL.ExecQuery("SELECT * from landshluti;")


     For i = 0 To Cursor.RowCount - 1
    Dim tt As personangsmnn
         Cursor.Position = i  '
   'Skoða betur Bitmap1.Initialize(ruta_imagen,crPlatos.GetString("myndnafn"))
   'Sækja myndina
   Dim Buffer() As Byte 'declare an empty byte array
    Buffer = Cursor.GetBlob("mynd")
    Dim InputStream1 As InputStream
    InputStream1.InitializeFromBytesArray(Buffer, 0, Buffer.Length)
   
    Dim Bitmap1 As Bitmap
    Bitmap1.Initialize2(InputStream1)
    InputStream1.Close
'   Activity.SetBackgroundImage(Bitmap1)
   'Sækja myndina Endir

   
    tt.hofundur=Cursor.GetString("hofundur")
    tt.forrit=Cursor.GetString("forrit")    

    ListView1.AddTwoLinesAndBitmap(tt.hofundur,tt.forrit,Bitmap1)
    Next
    Cursor.Close
    ProgressDialogHide

 
End Sub
 
Upvote 0
Top