I am using Android Amazing ListView to create a custom ListView with sticky headers. In this library, the data is being set inside Data.java class. What I need to do is, I have to pass the values for headers and list data for the headers from the database that I am creating locally. I am able to set the headers, however, I am not able to pass the list data according to those headers. The list data being populated is passed in the below format :
Composer[][] composerss = {
{
new Composer("Thomas Tallis"),
new Composer("Josquin Des Prez"),
new Composer("Pierre de La Rue"),
},
{
new Composer("Johann Sebastian Bach"),
new Composer("George Frideric Handel"),
new Composer("Antonio Vivaldi"),
new Composer("George Philipp Telemann"),
},
{
new Composer("Franz Joseph Haydn"),
new Composer("Wolfgang Amadeus Mozart"),
new Composer("Barbara of Portugal"),
new Composer("Frederick the Great"),
new Composer("John Stanley"),
new Composer("Luise Adelgunda Gottsched"),
new Composer("Johann Ludwig Krebs"),
new Composer("Carl Philipp Emanuel Bach"),
new Composer("Christoph Willibald Gluck"),
new Composer("Gottfried August Homilius"),
},
{
new Composer("Ludwig van Beethoven"),
new Composer("Fernando Sor"),
new Composer("Johann Strauss I"),
},
{
new Composer("Ludwig van Beethoven"),
new Composer("Fernando Sor"),
new Composer("Johann Strauss I"),
},
};
I need to know, how can I create a jagged array like this from the data that I am retrieving from the database. I am able to get the data according to the headers, but I need to pass it in this format, in order to arrange the data under the headers accordingly. Hope to get a help soon.
For getting the values from the database and create a jagged array, you may do something like below:
Take an ArrayList and store all the indexes in it.
Then you can generate the jagged array by using below method