【问题标题】:Openweathermap API How to make "q" dynamic and coincide with the input of search barOpenweathermap API 如何使“q”动态并与搜索栏的输入相吻合
【发布时间】:2016-03-05 20:05:04
【问题描述】:

大家好,我是 JSON 新手,所以我想创建一个“城市”搜索栏,以便用户可以使用 openweathermap API 检索该特定城市的天气。

这是您应该请求它的方式,但我想以这样一种方式制作“q”,以便当在搜索栏中正确键入城市时,它会自动检索该城市的数据。 "http://api.openweathermap.org/data/2.5/weather?q=Toronto,ca&units=metric&APPID=95d38c513c13444b6290e62403391b4e"

感谢您的帮助。

【问题讨论】:

    标签: javascript json rest weather-api openweathermap


    【解决方案1】:

    这里是我的:按城市搜索:

    public final static String URL = "http://api.openweathermap.org/data/2.5/weather?q=";
    public final static String yo = "&appid(your id)";
    public static final String unit_metric = "&units=metric";
    

    StringBuilder stringBuilder = new StringBuilder(URL + input + yo + unit_metric);
    

    您将从 editext 或其他文件获取输入的位置 例如:editext1.getText().toString().trim()

    String input= 存储在这里

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-07-03
      • 1970-01-01
      • 2021-10-29
      • 2020-12-06
      • 1970-01-01
      • 2018-05-14
      • 1970-01-01
      相关资源
      最近更新 更多