7

I have arraylist of powerUps and I want to display as a List view and whichever row user selects get that particular power for specific time. All thing is done except I am not able to display arraylist items on listview in libgdx. I searched a lot but didnt get any idea. I want something like this.

enter image description here

Nishant Anindya
  • 539
  • 5
  • 21

3 Answers3

2

If you want to use native android listview, you should refer this

But changing activity may not be such a good idea in most cases. So List class in scene2d would be a great choice here. You can simply initialize it with array of items and have a selection change listener to perform power-up selection. For more, refer this.

Daahrien
  • 10,190
  • 6
  • 39
  • 71
Tanmay Patil
  • 6,882
  • 2
  • 25
  • 45
1

I came accross with the alternative solution. implements gestureListener provided by Libgdx and used pan method.

Nishant Anindya
  • 539
  • 5
  • 21
1

Use ScrollPane

The tutorialsface implemented a sample...

ScrollPane scrollPane = new ScrollPane(get_long_actor___like_List());

and sample of the get_long_actor___like_List() :

private Actor get_long_actor___like_List() {
        Table table = new Table();
        //--------------------------------
        for (int i = 0; i < 30; i++)
        {
            table.row().center().padTop(10);
            table.add(new Label("Sample Item")).size(WIDTH, 50);
        }
        //--------------------------------
        return table;
}
ultra.deep
  • 1,699
  • 1
  • 19
  • 23