I'm trying to figure out how to display the items of an ArrayList which I have stored in a separate class into a ListView. I've been looking it up all day but the problem is that I can't find something like this specifically in which I had created a different class where I stored the ArrayList. It's a task I got for an internship and they asked me to use a local database or hardcode it so I chose to hardcode it.
import com.mircea.bookapp.Book;
import java.util.ArrayList;
public class Books
{
private ArrayList<Book> booklist;
public Books()
{
booklist = new ArrayList<Book>();
booklist.add(new Book("In Search of Lost Time", "Marcel Proust", 1913, "Modernist"));
booklist.add(new Book("Ulysses", "James Joyce", 1922, "Modernist novel"));
booklist.add(new Book("Don Quixote", "Miguel de Cervantes", 1612, "Novel"));
booklist.add(new Book("The Great Gatsby", "F. Scott Fitzgerald", 1925, "Tragedy"));
booklist.add(new Book("One Hundred Years Of Solitude", "Gabriel Garcia Marquez", 1967, "Magic realism"));
}
public Book getBook(int index)
{
return this.booklist.get(index);
}
}
This is the code from the Class from which I wanna get the info for the ListView.