How to load a Combobox in Firemonkey for Android

Asked

Viewed 553 times

-1

I have an Edit and next to it a Combobox. The idea is that Edit displays the registration id and combo the description. And when changing the combo option also change the id on Edit.

In the VCL to enter the description and the id like this:

Combo.AddObject('descricao',TObject (id))

But on Android this returns access Violation by data typing problems.

So my question is: how can I do this on Android?

2 answers

0


I managed to solve my problem differently While populating the combo with the description I populate a Stringlist with the ids. No change of Combobox I position the Stringlist in the same Index.

0

You can do it this way:

Combo.Items.AddObject('descricao', TObject(id));

To recover the id of the selected item in the combo:

id := Integer(Combo.Items.Objects[Combo.ItemIndex]);

And to change the id in Edit you can assign an Onchange event in Combo and assign the recovered value to Edit.

  • I don’t remember what you call the term a(cho that is Typecast), but on Android this does not work, because in Tobject (id) you are passing an entire object and Android does not accept. This link is better explained https://forums.embarcadero.com/thread.jspa?threadID=105411

  • Right, I ended up not testing on Android.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.