Sub GetViewAtPos(LV As ListView, Position As Int) As View
Dim r As Reflector
Dim v As View
r.Target = LV
Dim first As Int
first = r.RunMethod("getFirstVisiblePosition")
v = r.RunMethod2("getChildAt", Position - first, "java.lang.int")
Return v
End Sub
Sub ListView1_ItemClick (Position As Int, Value As Object)
Detail_Display(Value)
End Sub
ListView1.AddTwoLines2(Cursor.GetString("name"), Cursor.GetString("display_date"), Cursor.GetInt("_id"))
Sub lbl1_LongClick
Dim Send As View
Dim fetched_id, Obj As Int
Send=Sender
fetched_id=(Send.Tag)
Dim NumberOfMatchedrows As Int
NumberOfMatchedrows = SQL1.ExecQuerySingleResult("SELECT count(*) FROM favourite where fk_event_id = '" & fetched_id & "'")
End Sub
Sub CreateListItem(Text As String,ID As String, Width As Int, Height As Int) As Panel
Dim p As Panel
p.Initialize("")
p.Color = Colors.LightGray
'Dim b1,b2,b3 As Button
'b1.Initialize("b1") 'all buttons click events will be handled with Sub Button_Click
Dim lbl As Label
Dim lblID As Label
lblID.Initialize("")
lblID.Text = ID
lblID.Visible = False
lbl.Initialize("")
lbl.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.LEFT)
lbl.Text = Text
lbl.TextSize = 16
lbl.TextColor = Colors.White
p.AddView(lbl, 5dip, 2dip, 150dip, Height - 4dip) 'view #0
p.AddView(lblID, 5dip, 2dip, 150dip, Height - 4dip)
If ResponseID = 0 Then
Dim b1 As Button
b1.Initialize("b1")
b1.Color = Colors.RGB(77, 144, 254)
b1.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.CENTER_HORIZONTAL)
b1.TextColor = Colors.White
b1.Text = "Accept"
p.AddView(b1, 155dip, 2dip, 150dip, 40dip) 'view #1
Else If ResponseID = 1 Then
Dim b2 As Button
b2.Initialize("b2")
b2.Color = Colors.RGB(77, 144, 254)
b2.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.CENTER_HORIZONTAL)
b2.TextColor = Colors.White
b2.Text = "Request Sent"
p.AddView(b2, 155dip, 2dip, 150dip, 40dip) 'view #1
Else If ResponseID = 2 Then
Dim b3 As Button
b3.Initialize("b3")
b3.Color = Colors.RGB(244, 67, 54)
b3.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.CENTER_HORIZONTAL)
b3.TextColor = Colors.White
b3.Text = "Remove"
p.AddView(b3, 155dip, 2dip, 150dip, 40dip) 'view #1
End If
'p.AddView(lbl, 5dip, 2dip, 150dip, Height - 4dip) 'view #0
'p.AddView(lblID, 5dip, 2dip, 150dip, Height - 4dip)
'p.AddView(b, 155dip, 2dip, 150dip, 40dip) 'view #1
Return p
End Sub
Dim btn As Button
btn.Initialize("btn")
btn.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.CENTER_HORIZONTAL)
btn.TextColor = Colors.White
Select ResponseID
Case 0
btn.Color = Colors.RGB(77, 144, 254)
btn.Text = "Accept"
Case 1
btn.Color = Colors.RGB(77, 144, 254)
btn.Text = "Request Sent"
Case 2
btn.Color = Colors.RGB(244, 67, 54)
btn.Text = "Remove"
End Select
p.AddView(btn, 155dip, 2dip, 150dip, 40dip) 'view #1
I thought about this too, but every button needs a different action, for example, when the remove button is clicked it will have to send a DELETE FROM query and if the accept button is clicked it will have to send an UPDATE query so I think it has to be like this so I can have different actions depending on the button.You could simplify your code:
B4X:Dim btn As Button btn.Initialize("btn") btn.Gravity = Bit.OR(Gravity.CENTER_VERTICAL, Gravity.CENTER_HORIZONTAL) btn.TextColor = Colors.White Select ResponseID Case 0 btn.Color = Colors.RGB(77, 144, 254) btn.Text = "Accept" Case 1 btn.Color = Colors.RGB(77, 144, 254) btn.Text = "Request Sent" Case 2 btn.Color = Colors.RGB(244, 67, 54) btn.Text = "Remove" End Select p.AddView(btn, 155dip, 2dip, 150dip, 40dip) 'view #1
It makes no difference. Your btn_Click event can tell which button has been pressed based, for example, on the button's Text value. Sender is the object that you need to work with.I thought about this too, but every button needs a different action, for example, when the remove button is clicked it will have to send a DELETE FROM query and if the accept button is clicked it will have to send an UPDATE query so I think it has to be like this so I can have different actions depending on the button.
Oh right that's true! I'll try that then, thanks!It makes no difference. Your btn_Click event can tell which button has been pressed based, for example, on the button's Text value. Sender is the object that you need to work with.
That sounds strange to me!customlistview.jumpto(customlistview.getsize) get not the last index.
That sounds strange to me!
I suspect the customlistview is larger than the screen and so the last item(s) are actually out of view?Hallo,
i'm use the CustomListview with many items from a database.
customlistview.jumpto(customlistview.getsize) get not the last index.
Also the scrolling finished not at last index. I suspect a problem with the itemhight.
How can I solve the problem?
Geritt
Yes, they are out of view.
In LOG getsize value is correct.
But item_click to the last visible and scrolling item receive an index lower then getsize-value.
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?
We use cookies and similar technologies for the following purposes:
Do you accept cookies and these technologies?