1

我有以下 for 循环代码不适用于 4.2\API17。代码调用数据模型类并进行迭代。Logcat 表明这种情况正在发生。我正在尝试让 Plist(xml) 解析器工作。在 2.2\API 8 上一切正常

         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());

      }

日志猫

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

非常感谢任何线索或指导。

4

1 回答 1

0

尝试在onCreate方法中使用以下几行:

StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
    StrictMode.setThreadPolicy(policy);
于 2013-08-02T16:41:54.763 回答