Android Tutorial ListView tutorial

klaus

Expert
Licensed User
Longtime User
From the ListView help:
ListView.GetItem

Method

Returns the value of the item at the specified position.
Returns the "return value" if it was set and if not returns the text of the first line.

Returns : Object

GetItem(Index As Int)
Have you installed agrahams help viewer ?

Best regards.
 

Dogbonesix

Active Member
Licensed User
Longtime User
Back to the Listview

Amazing Support.

I did find:
=================
SetSelection (Position As Int)
Sets the currently selected item. Calling this method will make this item visible.
If the user is interacting with the list with the keyboard or the wheel button the item will also be visibly selected.
Example: ListView1.SetSelection(10)
=================

But it does not seen to work...

I am updating a MySql table and I just want the Listview to return the item that was clicked. Some list can be very long...

In my example below I just want the listview to show Item 15 and not be at the top to avoid scrolling.

My Code Below: Label5_Click
====================
Sub Label5_Click
F3 = Label3.Text
F4 = Label4.text
' Table Field #1 Field #2
ExecuteRemoteQuery("UPDATE x1_my_desk SET ActualCount = " & "'" & F3 & "'" & " , ReOrderQty = " & "'" & F4 & "'" & " WHERE Deskitem = " & "'" & F2 & "'", Q_UPDATE)

ExecuteRemoteQuery("SELECT Deskitem, ActualCount, ReOrderQty, UnitOf FROM x1_my_desk where Desk = " & "'" & F1 & "'" & " order by Deskitem", Q_SELECT)
ListView1.SetSelection(15)

ListView1.Visible = True
ToastMessageShow("...Changes Posted...",True)
End Sub
=====================
Thanks
 

Informatix

Expert
Licensed User
Longtime User

beto1062

Member
Licensed User
Longtime User
How to update a ListView Item

Hi,
I´m loading manually a ListView with some data I reed from the internet and I need to update the items.
I dont know the item # I know what is in the first line.
How can I do it?
Thanks
 
Last edited:

beto1062

Member
Licensed User
Longtime User
CustomListView help

Hi I´m playing with the example.

I have a Data Table with Labels and quantyties.
With a Timer I go trought the internet and get some values.
In any value change I need to go and search the Item in the customlistview and change it.
How can I do it?
And.. can I SORT the customlistview ?

I'm trying to do something like "Tader Pulse" ( see: https://market.android.com/details?id=com.uncledroid.traderpulse )

Thanks
 
Last edited:

tub

New Member
Licensed User
Longtime User
Listview - Simple questions

Hi, how do I reduce the spacing for each text item of a listview, when using "AddSingleLine" as they are spaced quite far apart. Also, how do I modify the text of each item through my program?

Thanks!
 

bjf

Member
Licensed User
Longtime User
Anyone got a tip for how i can "update" a listview on for example itemclick?

I use a listview to display files in a remote FTP folder.
if i click an item, that item/file is downloaded to the device.

When the file has been downloaded i would like to update the row with for example a bitmap that indicates that that item/file has been downloaded.
 

electronik54

Member
Licensed User
Longtime User
Listview turns background black every time i scroll it

:sign0085: Listview turns background black every time i scroll it. the text and functioning remains as it is only background color changes. this only happens on samsung galaxy tab(2.2.1) works fine on other devices with ICS.
any solution?
 

electronik54

Member
Licensed User
Longtime User
Problem with click in listview

:sign0085::sign0104: :sign0085::sign0104:

B4X:
Sub search_FA_button_click
   
   currentPage="searchFAlist"
   Dim Position As Int
   Dim Findrow As Int = Position
   Dim Cursor15 As Cursor

   Dim FA As String
   FA=FA_ser.Text
   
   If    FA.Length=0 Then
      ToastMessageShow("Please Fill the above field",False)
      Else
      'ToastMessageShow("search by FA",False)
      Cursor15 = SQL1.ExecQuery("Select * FROM FAid WHERE Situation like '%"& FA &"%' ")
      Cursor15.Position = Findrow
   End If
   
   If Cursor15.rowcount>0 Then
      If FA.Length>0 Then
      Activity.RemoveAllViews
      Activity.RemoveView
   
      Activity.LoadLayout("Flist.bal")
      Activity.LoadLayout("faith.bal")
   
      Dim moreinfoBtn As Bitmap
      moreinfoBtn.Initialize(File.DirAssets, "moreinfobtn.png")
      
      Dim sevr As String
      sevr=""&Cursor15.GetString("Severity")
      
      
      For i = 0 To Cursor15.RowCount - 1
      Cursor15.Position = i
         FA_s_lv.ScrollingBackgroundColor = Colors.White
         FA_s_lv.TwoLinesAndBitmap.Label.TextSize = 15
         FA_s_lv.TwoLinesAndBitmap.Label.TextColor = Colors.Black
         FA_s_lv.TwoLinesAndBitmap.SecondLabel.TextSize = 13
         FA_s_lv.TwoLinesAndBitmap.SecondLabel.TextColor = Colors.DarkGray
          FA_s_lv.AddTwoLinesAndBitmap((Cursor15.GetString("Situation")),(Cursor15.GetString("Severity")),moreinfoBtn)
         
      Next

      ToastMessageShow("" &Cursor15.RowCount& " Results Found", False)
      
      End If
   Else 
   ToastMessageShow("No Results Found",False)      'in case cursor15 is empty
   End If
End Sub
___________

what this code does is that it searches the DB places the results in the listview. so what happens is when i click on the first item in the list it displays info about the first entry in the DB when it should be displaying the info about the clicked item.

please correct my code if you have any solutions
 

stevel05

Expert
Licensed User
Longtime User
You don't seem to be assigning a value to FindRow, you are Dimming Position as Int which defaults to 0, then assigning that to FindRow, which will mean the first row will always be returned.


You should also test that Cursor15.rowcount >= Findrow otherwise an error will occur, it probably will be if you are using the same list, but better safe than sorry.
 
Last edited:
Top