简体   繁体   English

Android:XML从API到MainActivity中的XML

[英]Android: XML from API to XML in MainActivity

This Question may be hard to present, but I'll give it a go. 这个问题可能很难提出,但我会尝试一下。

So I am attempting to create an application within Android Studio that determines what phase the moon is currently in. After some research, I didn't really find anything but then I found timeanddate.com offer Astronomy API packages. 因此,我试图在Android Studio中创建一个确定月球当前处于哪个相位的应用程序。经过一些研究,我并没有真正找到任何东西,但是后来我发现timeanddate.com提供了Astronomy API程序包。

I gave the trial a go, which came with the moon phases. 我给了试用期,它与月相同时出现。

Now I used a Query Builder to essentially guide me through getting the Results in XML, and received the following: 现在,我使用查询生成器从本质上指导我获取XML格式的结果,并收到以下信息:

    <?xml version="1.0" encoding="UTF-8"?>
<data version="2">
  <location id="750">
    <geo>
      <name>Lord Howe Island</name>
      <state>Lord Howe Island</state>
      <country id="au">Australia</country>
      <latitude>-31.557</latitude>
      <longitude>159.086</longitude>
    </geo>
    <astronomy>
      <object name="moon">
        <day date="2018-09-03" moonphase="thirdquarter">
          <event type="thirdquarter" isotime="2018-09-03T13:07+10:30" hour="13" min="7"/>
        </day>
      </object>
    </astronomy>
  </location>
</data>

So I have the data, now I am stuck at actually getting it on an Activity in Android Studio. 所以我有了数据,现在我只能在Android Studio的Activity上实际获取它。

To the extent of my knowledge, XML in Android Studio does not look like the XML I received, with lines such as 据我所知,Android Studio中的XML看起来不像我收到的XML,其行如下

 android:text="text"

Can someone point me in the right direction? 有人可以指出我正确的方向吗? I have no idea where to go from here, now that I have some information to work with. 现在,我已经掌握了一些信息,因此我不知道该从哪里去。 Clearly, this is not a matter of copy and paste the XML from time and date. 显然,这与从时间和日期复制和粘贴XML无关。 I just don't know the next steps to show something like " Lord Howe Island, Third Quarter Moon" (As seen in the XML supplied) 我只是不知道接下来要显示类似“ 豪勋爵岛,第三季月亮”之类的步骤(如提供的XML中所示)

Thanks, everyone, even the tiniest of help is useful. 谢谢大家,即使是最小的帮助也很有用。

Well you have to issue the API request in the background, parse the result and update the UI. 好了,您必须在后台发出API请求,解析结果并更新UI。

This has anything you will need: https://developer.android.com/training/basics/network-ops/xml 这具有您需要的一切: https : //developer.android.com/training/basics/network-ops/xml

Feel free to ask for more info! 随时要求更多信息!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM