誰能告訴我什麼是錯我的代碼ArrayList的奇怪行爲
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.as我寫這在我的項目中兩個的ArrayList(latest_songs和top_songs)與hits_songs.where我做錯overrided數據,它工作正常。
這是從我在每一個ArrayList中
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;
}
在哪裏可以得到其餘的歌曲我的意思是代碼? –
所以我們必須猜測代碼,你是怎麼寫的? –
我不確定我是否有能力爲您提供答案...... – MadProgrammer