谁能告诉我我的代码有什么问题
latest_songs、top_songs 和 hit_songs 是 arraylist.song() 是 Parseurl 中的静态方法,我在其中获取 json array.it 工作正常并返回正确的数据。
latest_Songs = ParseUrl.song(url1);
Log.i("ring,latest=", latest_Songs.toString());
top_Songs = ParseUrl.song(url2);
Log.i("ring,top=", top_Songs.toString());
hit_Songs = ParseUrl.song(url3);
Log.i("ring,hits=", hit_Songs.toString());
当我运行 latest_songs 并且 top_songs.problem 与 hit_songs 一起运行时,它工作正常。因为我在我的项目中写了这个,arraylist(latest_songs 和 top_songs)数据都被 hits_songs 覆盖。我做错了。
这是 ParseUrl,我从中检索每个数组列表中的数据
public class ParseUrl {
static ArrayList<String> songs_List = new ArrayList<String>();
static ArrayList<String> songs_Names = new ArrayList<String>();
static ArrayList<String> songs_Urls = new ArrayList<String>();
static File tempFiles;
File ringtones;
public static ArrayList<String> song(String url) {
songs_Names.clear();
songs_Urls.clear();
JSONObject json = JsonParse.getSongfromUrl(url);
try {
JSONArray latestSongs = json.getJSONArray("ringtones");
for (int count = 0; count < latestSongs.length(); count++) {
JSONObject song = latestSongs.getJSONObject(count);
songs_List.add(song.toString());
JSONArray name = song.names();
songs_Names.add(name.toString());
String songUrl = name.toString();
String URL = songUrl.substring(2, songUrl.lastIndexOf("\""));
songs_Urls.add(song.getString(URL));
}
} catch (JSONException e) {
e.printStackTrace();
}
return songs_Names;
}