我有 my_songs
表,包括列:
id (int)
name (varchar)
title (varchar)
photo_url (string)
lyrics (string)
date (date)
info (string)
genre (varchar)
file_size (int)
mp3_url (string)
我的表格包括 10,000 行。我使用 volley
库在我的应用程序的 ListView 中加载歌曲列表:
select id, name, title, photo_url from my_songs limit 1,20 .....
当用户点击 ListView 项目时:
select * from my_songs where id = click_item
现在,listview mysongs list arrayList 哪个更好:
A.
class songsListModel() {
int id;
string name;
string title;
string photo_url;
}
List<songsListModel> songs_list_for_listview = select id, name, title, photo_urel from my_songs;
或
B.
class songsListModel() {
int id;
string name;
string title;
string photo_url;
string mp3_url;
string genre;
string date;
string lyric;
string info;
intfile_size;
}
List<songsListModel> songs_list_for_listview = select * from my_songs;
我不想在服务器上点击项目请求以获取其他歌曲详细信息,例如 lyric、mp3_url、genre 和 ....
。
在A方法中,数组中的数据量很大,不会造成什么问题?哪个更好?
最佳答案
从我的角度来看,选项 A. 比 B. 好,因为根据该请求,用户查看列表的时间会更少。当他们点击时,您可以播放歌曲并同时加载有关歌曲的其他信息。因此,用户不会厌倦看到加载。
关于android listview和arrayList数据优化,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37584894/