Move an item to the top of list

I am having a list of more than 10 items and trying to make a favorite system. Like when a user long clicks on any item, it moves it to the top of list and previous top item goes to the second position and so on. Please point on to what to search to achieve this result.

Hi @Sarmad_Khan,

Hope this helps. Sorry that this is from my MIT App Inventor tutorial, I took it from my own document.

Let’s say if I have 3 items: A,B,C, and 3 buttons, each named AButton, BButton and CButton.

Designer:

Blocks:

In the blokcs, the variable ‘list’ is the list you want. You will have to copy the variable and name it to ‘list2’ and an empty list variable named ‘list3’.

In your own app, you can do the same, only the variables list and list2 is your own 10-item list.

Note: To append list B to list A (only for example) means to add every item in list B to list A. For example, if list A has items apple, orange; while list B has banana, grapes, the final list A would be apple,orange, banana, grapes.

Or, if you don’t like the event ‘when anyButton. Click’ and want to replace it, these blocks might help you.

3 Likes

This is simple and good. You can follow this @Sarmad_Khan

1 Like

Does it work with long click? Currently its not working for me.

Use clear list block just above all these block, i hope it will work for you upon user long click

Not working

What’s not working ? Show us your blocks

blocks
Following the same method as suggested.

Have you enabled long click from listview’s advanced properties? Enable it and it will work

image

1 Like

I did now. Working great again. One thing though, why put it as an option? Why it can’t be enable by default?

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.