2013-08-02 68 views
1

我有下面的循環代碼將無法在4.2 \ API17工作。代碼調用Data Model類並進行迭代。 Logcat顯示正在發生。我正在嘗試使Plist(xml)解析器正常工作。這一切工作正常在2.2 \ API 8爲什麼for循環不適用於平臺4.2(API 17)?

  String xml = readPlistFromAssets(); 
     // create object of Parser Class 
     ParsePlist pp = new ParsePlist(); 
     // parse Plist and fill in plist array 
     ArrayList<DataModel> plist = pp.parsePlist(xml); 
     // Print ArrayList 
     Iterator<DataModel> i = plist.iterator(); 


     Log.i("Plist","======================33==="); 

     for(String key = null; i.hasNext();) 
     { 


      Log.i("Plist","==========for loop======="); 
      DataModel d = i.next(); 
      eventT = d.getEventTitle(); 


      Log.v("Event Title...........", eventT); 

     } 


     while(i.hasNext()){ 

      DataModel d = i.next(); 
      Log.i("Plist","========================="); 
      Log.i("Plist","Descript: " + d.getAbout()); 
      Log.i("Plist","BandName: " + d.getTitle()); 
      Log.i("Plist ", "Venu: " + d.getVenue()); 

     } 

logcat的

08-02 16:30:22.165: W/Trace(3670): Unexpected value from nativeGetEnabledTags: 0 
08-02 16:30:35.447: W/Trace(4311): Unexpected value from nativeGetEnabledTags: 0 
08-02 16:30:35.447: W/Trace(4311): Unexpected value from nativeGetEnabledTags: 0 
08-02 16:30:36.077: D/dalvikvm(4311): GC_FOR_ALLOC freed 72K, 7% free 2520K/2708K, paused 68ms, total 71ms 
08-02 16:30:36.077: I/dalvikvm-heap(4311): Grow heap (frag case) to 3.158MB for 614416-byte allocation 
08-02 16:30:36.155: D/dalvikvm(4311): GC_FOR_ALLOC freed 1K, 6% free 3119K/3312K, paused 69ms, total 69ms 
08-02 16:30:36.245: D/dalvikvm(4311): GC_CONCURRENT freed <1K, 6% free 3119K/3312K, paused 5ms+3ms, total 90ms 
08-02 16:30:36.394: D/dalvikvm(4311): GC_FOR_ALLOC freed <1K, 6% free 3119K/3312K, paused 34ms, total 34ms 
08-02 16:30:36.415: I/dalvikvm-heap(4311): Grow heap (frag case) to 4.199MB for 1093136-byte allocation 
08-02 16:30:36.568: D/dalvikvm(4311): GC_CONCURRENT freed 0K, 5% free 4186K/4380K, paused 5ms+14ms, total 85ms 
08-02 16:30:36.675: W/Trace(4311): Unexpected value from nativeGetEnabledTags: 0 
08-02 16:30:36.675: W/Trace(4311): Unexpected value from nativeGetEnabledTags: 0 
08-02 16:30:36.698: W/Trace(4311): Unexpected value from nativeGetEnabledTags: 0 
08-02 16:30:36.736: W/Trace(4311): Unexpected value from nativeGetEnabledTags: 0 

08-02 16:30:37.274: D/gralloc_goldfish(4311): Emulator without GPU emulation detected. 
08-02 16:30:37.844: W/Trace(4311): Unexpected value from nativeGetEnabledTags: 0 
08-02 16:30:37.905: W/Trace(4311): Unexpected value from nativeGetEnabledTags: 0 
08-02 16:30:39.636: W/Trace(4311): Unexpected value from nativeGetEnabledTags: 0 
08-02 16:30:39.804: W/Trace(4311): Unexpected value from nativeGetEnabledTags: 0 
08-02 16:30:39.804: W/Trace(4311): Unexpected value from nativeGetEnabledTags: 0 
08-02 16:30:40.104: D/dalvikvm(4311): GC_FOR_ALLOC freed 664K, 19% free 3617K/4420K, paused 155ms, total 170ms 
08-02 16:30:40.104: I/dalvikvm-heap(4311): Grow heap (frag case) to 4.229MB for 614416-byte allocation 
08-02 16:30:40.264: D/dalvikvm(4311): GC_CONCURRENT freed <1K, 5% free 4217K/4420K, paused 6ms+52ms, total 123ms 
08-02 16:30:40.664: D/dalvikvm(4311): GC_FOR_ALLOC freed <1K, 5% free 4217K/4420K, paused 63ms, total 63ms 
08-02 16:30:40.704: I/dalvikvm-heap(4311): Grow heap (frag case) to 5.271MB for 1093136-byte allocation 
08-02 16:30:40.904: D/dalvikvm(4311): GC_CONCURRENT freed 0K, 4% free 5284K/5488K, paused 84ms+20ms, total 203ms 
08-02 16:30:41.274: D/LOG_TAG(4311): PATH: /mnt/sdcard/download/ 
08-02 16:30:41.274: I/Plist(4311): ======================1=== 
08-02 16:30:41.294: I/Plist(4311): =======================2== 
08-02 16:30:41.534: I/Plist(4311): =======================3== 
08-02 16:30:41.564: I/Plist(4311): ======================22=== 
08-02 16:30:42.764: I/Hit(4311): **********************Parse Plist******** hit *** 
08-02 16:30:42.784: I/Hit(4311): 222222222222222****Parse Plist******** hit *** 
08-02 16:30:42.784: I/Hit(4311): **********************Parse Plist******** hit *** 
08-02 16:30:42.804: I/Hit(4311): 222222222222222****Parse Plist******** hit *** 
08-02 16:30:42.804: I/Hit(4311): **********************Parse Plist******** hit *** 
08-02 16:30:42.824: I/Hit(4311): 222222222222222****Parse Plist******** hit *** 
08-02 16:30:42.824: I/Hit(4311): **********************Parse Plist******** hit *** 
08-02 16:30:42.844: I/Hit(4311): 222222222222222****Parse Plist******** hit *** 
08-02 16:30:42.844: I/Hit(4311): **********************Parse Plist******** hit *** 
08-02 16:30:42.864: I/Hit(4311): 222222222222222****Parse Plist******** hit *** 
08-02 16:30:42.898: I/Hit(4311): **********************Parse Plist******** hit *** 
08-02 16:30:42.904: I/Hit(4311): 222222222222222****Parse Plist******** hit *** 
08-02 16:30:42.916: I/Hit(4311): **********************Parse Plist******** hit *** 
08-02 16:30:42.944: I/Hit(4311): 222222222222222****Parse Plist******** hit *** 
08-02 16:30:42.944: I/Hit(4311): **********************Parse Plist******** hit *** 
08-02 16:30:42.964: I/Hit(4311): 222222222222222****Parse Plist******** hit *** 
08-02 16:30:45.784: I/Plist(4311): ======================33=== 
08-02 16:30:45.916: W/Trace(4311): Unexpected value from nativeGetEnabledTags: 0 
08-02 16:30:45.916: W/Trace(4311): Unexpected value from nativeGetEnabledTags: 0 

任何線索或指導是極大的讚賞。

+0

檢查logcat的任何異常發生? –

+0

沒有,我看到。都似乎是信息。我會發布,以防萬一我失去了一些東西。 – AhabLives

+0

是否使用任何線程類或AsyncTask從網絡獲取xml數據 –

回答

0

嘗試使用以下行onCreate方法:

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); 
    StrictMode.setThreadPolicy(policy); 
+0

「StrictMode無法解析爲類型」與 AhabLives

+0

否,請勿禁用'StrictMode' - 修正它試圖阻止您造成的問題。 – zapl