我正在将OpenWeatherMapsAPI 用于天气应用程序,但它在某些城市显示小数,如何从中删除小数部分?
override fun onPostExecute(result: String?) {
super.onPostExecute(result)
try {
val jsonObj = JSONObject(result)
val main = jsonObj.getJSONObject("main")
val temp = main.getString("temp")+"°C"
findViewById<TextView>(R.id.temp).text = temp
Run Code Online (Sandbox Code Playgroud)