【问题标题】:How fix the loop that repeat the satellite information in the list?如何修复列表中重复卫星信息的循环?
【发布时间】:2013-05-31 07:27:09
【问题描述】:

我创建了一个显示 gps 传感器卫星信息的应用程序。但是迭代器循环不对,信息显示为文本永远不会停止更新。我想要每颗卫星的唯一信息,而不是相同的信息。如何修复它?

  if (statoGps != null) {
                Iterable<GpsSatellite> listSat = statoGps.getSatellites();
                Iterator<GpsSatellite> sat = listSat.iterator();
                int visibleSats = 0;
                while (sat.hasNext()) {
                   GpsSatellite satellite = sat.next();
                   gpsStats += "SATELLITE " + (visibleSats++) + 
                                  "PRN: " + satellite.getPrn() +                     
                                  "SNR: " + satellite.getSnr() + 
                                  "azimuth: " + satellite.getAzimuth() + 
                                  "el: " + satellite.getElevation() + 
                                  "fix: " + satellite.usedInFix() + "\n"; 


                }
                elencoSat.setText(gpsStats);  
             }   

【问题讨论】:

    标签: android gps satellite


    【解决方案1】:

    尽量去掉while循环,只保留内部代码。这将只打印一次信息。

    【讨论】:

    • 谢谢,但不起作用...我在 while 循环之前解决了清除 gpsStats...
    猜你喜欢
    • 1970-01-01
    • 2011-03-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-24
    • 1970-01-01
    相关资源
    最近更新 更多