Android Question ListView issue....

Tyler

Member
Licensed User
Longtime User
Hey guys! For some reason this code to add stuff to my listview only works once and then the listview disappers for some reason. Here's my code:


B4X:
Sub Globals
Dim val As Object
End Sub


Sub listoutput_ItemClick (Position As Int, Value As Object)
   
    listoutput.Clear
    val = Value
    timer7.Initialize("timer7", 500)
    timer7.Enabled = True
End Sub

Sub timer7_Tick
          
    ssh3.Initialize("ssh3", hostname.Text, port.Text)
    ssh3.authenticateWithPassword(username.Text, password.Text)
    ssh3.execCommand("cd " & val & " && " & "ls", 16)
   
    timer7.Enabled = False
   End Sub

Sub ssh3_CmdExecuted (Success As Boolean, Result As List, TaskId As Int)
    Dim count As Int
    count = 0
   Do While count < Result.Size
    listoutput.AddSingleLine(Result.Get(count))
   count = count + 1
   Loop
  
 
  
   End Sub
 

derez

Expert
Licensed User
Longtime User
I don't know if this is the reason but the use of do while here is wrong. use simple loop:

Sub ssh3_CmdExecuted (Success AsBoolean, Result AsList, TaskId AsInt)
for i = 0 to Result.Size - 1
listoutput.AddSingleLine(Result.Get(i))
next
End Sub
 
Upvote 0

DonManfred

Expert
Licensed User
Longtime User
For some reason this code to add stuff to my listview only works once and then the listview disappers for some reason.

Wrong.The Listbox did not dissappear.
It´s the content of the listbox which is cleared.The Listbox is there but empty cause of your code


Here's my code:

B4X:
Sub listoutput_ItemClick (Position As Int, Value As Object)
    listoutput.Clear
    val = Value
    timer7.Initialize("timer7", 500)
    timer7.Enabled = True
End Sub

The
B4X:
listoutput.Clear
is the problematic line... You clear the Listbox on an click on an item. And then, o wonder, the List (it´s content) disappears :D
 
Last edited:
  • Like
Reactions: eps
Upvote 0

Tyler

Member
Licensed User
Longtime User
I've tried without having listouput.clear there and it still has the same result. Interesting thought about putting if success = true then but would that make any difference?

EDIT: Nope, it didn't make a difference at all. Damn this is confusing :confused:
 
Last edited:
Upvote 0
Top