接着上一步的操作,上一步已经能实现一个最简单的天气预报了
https://blog.youkuaiyun.com/weixin_44889138/article/details/102797849
源码地址:https://github.com/LGH-cmd/android_weather.git
下面加入能够刷新天气预报的功能
刷新时获得数据要有一定的时间,可以增加一个alertDialog,提醒用户正在加载
其中**setView()**方法可以自定义一个view
首先实现简单一个加载
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
点击按钮后去加载
btnX.setOnClickListener(new