第八篇-10分钟创建一个小游戏:幸运大抽奖

一、新建一个empty activity项目

二、切换到Design页面

去掉下方连接,width改为match,textAlignment选择center。textSize: 200sp,textColor: colorAccent,id: LuckyNumber(id名字不可以有空格)。

拖一个Button,text: Draw Number,连接左右下, match。切换到text模式,在Button标签下添加android:onClick="drawNumber";

在mainActivity.java中添加drawNumber的函数。

可以去运行小程序啦。

原文地址:https://www.cnblogs.com/smart-zihan/p/9825247.html