• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

how to add value against each listview item

 
Pallab Pal
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys someone help me.
I am new in Javafx....my problem is i want to add integer value against each ListView item. How can i implement this? My code is given below

@FXML
ListView<String> lvDevice;

ObservableList<String> data = FXCollections.observableArrayList(
"test1", "test2", "test3", "test4", "test5");

@Override
public void start(Stage stage) {
lvDevice.setItems(data);
}

-------------------------------------
Now I want add integer value against each item say for test1-1, for test2-2 like that.....Please help me! Thanks.
 
Vasilis Souvatzis
Ranch Hand
Posts: 81
1
Chrome Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See if the FXCollections.replaceAll(...) method works for you.

Otherwise, I guess you could iterate the list, retrieve each data, change it and re-add it to the list.
 
Pallab Pal
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you please give me an example of using iterate
 
Vasilis Souvatzis
Ranch Hand
Posts: 81
1
Chrome Java Netbeans IDE
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's basically a for loop that goes through the List. I'm writing this out of my head but it should go this way:



Check your IDE for code completion but I'm fairly certain it goes similarly.
 
John Damien Smith
Ranch Hand
Posts: 296
14
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic