Android Question Listviewitem with "payload"

FlyingEagle

Member
Licensed User
Longtime User
Hello,

After hours of searching, I'm still no closer to a solution.

I have now managed that I can insert a previously defined view as item in several xcustomlistviews.

This item-view has two buttons and a label.

I would now like to click on the label according to branch in the code to display dependent on the selection data. I would like to load this data from a text file - but do not know in which format (are rather few data, database would probably be too large).

My biggest problem, however, is the determination of the clicked items and the two respective buttons.
in other words, I have only been able to determine the events from the view only from a listview so far, if for example I do the same from the second or third listview my code will not work or the app will be closed.

this is an example from erel:
B4X:
Dim index As Int = LV1.GetItemFromView (Sender)
Dim pnl As B4XView = LV1.GetPanel (index)
Dim lbl As B4XView = pnl.GetView (0)
Log ("Edit Clicked!")

Now the most important questions:

1. how do I have to insert the items so that they have an index as a payload, for example?
2. which do i determine the clicks on the 3 elements within the view?
3. how does this work out of nth - listviews?

Question on the edge
4. Is it possible to open an autocompletition text field by code / focus without the user has made an input to use it as a kind of spinner?

Many Thanks

PS:
I'm just trying to beat a very steep learning curve, but still I'm losing the urge to keep going
 

Peter Simpson

Expert
Licensed User
Longtime User
Have you tried to use the click events?

Index and Value gives you what you need if you click directly on the xCLV.
B4X:
'ITEM LINE CLICK EVENT
Sub xCLV_ItemClick(Index As Int, Value As Object)
'Log("Short")
End Sub

You hace 2 buttons, have you tried catching the button clicks by using a sender or B$XView?
B4X:
Sub Button1_Click
Dim index As Int = CLV.GetItemFromView(Sender)
End Sub

Thinking about it, you should quickly play with the xCustomListView example, you will quickly figure our what you have missed, it's really easy if you follow look at what Erels example is doing...
 
Upvote 0

Peter Simpson

Expert
Licensed User
Longtime User
BUT, what if i have 2,3,4,5 CLVs?
Each CLV will have its own click event sub.

dies event is not fired ... only the click events of the two buttons and the label, but not this itemclick-event
Make sure that you do not have any spelling mistakes.

Erels example covers everything that you are trying to do. You should use Erels example code and place break points in his subs, you will then see how everything works whe. you click on any of the views.
 
Upvote 0

FlyingEagle

Member
Licensed User
Longtime User
I have found some things out.

when i add a new text-item to the xCLV then the itemclick-event is fired.
when i add a custom-item (pre-defined layout with designer) then only the click-events of the views i added in designer are fired but NOT the itemclick-event - only if you click on the background of the inserted custom-item / view the itemclick-event is fired.
 
Upvote 0
Top