【问题标题】:android listview and arrayList data optimizationandroid listview和arrayList数据优化
【发布时间】:2016-10-01 18:42:47
【问题描述】:

我有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 库在我的应用程序的列表视图中加载歌曲列表:

 select id, name, title, photo_url from my_songs limit 1,20 .....

当用户点击列表视图项时:

 select * from my_songs where id = click_item

现在,哪个更适合listview mysongs list arrayList:

答。

 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 and ....

A方法中,数组中的数据量很大,不会造成什么问题吗?哪个更好?

【问题讨论】:

    标签: android mysql arrays database listview


    【解决方案1】:

    从我的角度来看,选项 A. 比 B. 更好,因为根据该请求,用户查看列表的时间会更少。当他们点击时,您可以播放歌曲并并行加载有关歌曲的其他信息。因此,用户不会厌倦看到加载。

    【讨论】:

    • 如果您觉得答案有帮助,您可以接受。
    • 欢迎你 :) @grizzly
    猜你喜欢
    • 1970-01-01
    • 2017-04-04
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-05-25
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多