Android 天气APP(三十一)每日提醒弹窗

增加位置如下:

Android 天气APP(三十一)每日提醒弹窗_第1张图片

然后进入SplashActivity,重写getBiYingResult方法,代码如下:

/**

  • 必应壁纸数据返回

  • @param response BiYingImgResponse

*/

@Override

public void getBiYingResult(Response response) {

if (response.body().getImages() != null) {

//得到的图片地址是没有前缀的,所以加上前缀否则显示不出来

String biyingUrl = “http://cn.bing.com” + response.body().getImages().get(0).getUrl();

SPUtils.putString(Constant.EVERYDAY_TIP_IMG,biyingUrl,context);

} else {

ToastUtils.showShortToast(context, “未获取到必应的图片”);

}

}

这里你会发现Constant.EVERYDAY_TIP_IMG,没有这个属性值,那么就到Constant中去创建。

/**

  • 每日提示弹窗的背景图

*/

public static final String EVERYDAY_TIP_IMG = “everydayTipImg”;

/**

  • 每日提示弹窗是否弹出

*/

public static final String EVERYDAY_POP_BOOLEAN = “everydayPopBoolean”;

在Constant里面增加这两个系统变量,注释已经说明了这两个变量的用途了。

下面在layout中新建一个dialog_everyday_tip.xml。里面的代码如下:

xmlns:app=“http://schemas.android.com/apk/res-auto”

android:layout_width=“@dimen/dp_270”

android:layout_height=“wrap_content”

android:orientation=“vertical”>

android:id=“@+id/iv_dialog_bg”

android:layout_width=“match_parent”

android:layout_height=“420dp”

android:foreground=“@drawable/shape_dialog_foreground_bg_12”

android:scaleType=“fitXY”

android:src=“@drawable/img_5”

app:shapeAppearanceOverlay=“@style/roundedImageStyle” />

android:layout_width=“match_parent”

android:layout_height=“420dp”

android:padding=“@dimen/dp_12”>

android:id=“@+id/tv_week”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:text=“星期四”

android:textColor=“@color/white”

android:textSize=“@dimen/sp_20”

android:textStyle=“bold” />

android:id=“@+id/tv_temperature”

android:layout_width=“wrap_content”

android:layout_height=“wrap_content”

android:layout_below=“@+id/tv_week”

android:text=“温度”

android:textColor=“@color/white”

android:textSize=“@dimen/sp_48” />

你可能感兴趣的:(android)