一、运行效果
1、运行程序,进入如下图显示界面:
2、输入用户名和密码,点击登录,进入下图界面:
这时小宝宝的上方会显示刚刚你登录的用户名,证明是你的宝宝。。
3、点击主人购买装备,进入下图界面:
选择你购买的商品,商品的属性值是不一样的,第一次先选择金剑。。
4、点击购买金剑,进入下图界面:
宝宝的属性值会根据商品的属性值而增加,
再点击一次主人购买装备,选择盔甲。。
5、点击购买盔甲,进入下图界面:
宝宝的属性值根据盔甲的属性值而增加。。
二、设计思路
1、先创建每个界面对应的layout布局文件
2、再创建每个布局对应的class类,编写界面交互代码
3、然后在清单文件中配置每个Activity
4、最后,运行程序
三、用到的布局文件和class类文件
四、具体实现过程代码
1、登录界面布局文件(activity_login.xml)具体代码如下所示:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="username:"
android:textSize="25sp"/>
<EditText
android:id="@+id/et1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:hint="Please Input"
android:gravity="center"/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="password:"
android:textSize="25sp"/>
<EditText
android:id="@+id/et2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2"
android:hint="Please Input"
android:gravity="center"
android:inputType="textPassword"/>
</LinearLayout>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:text="登录"
android:onClick="gomain"/>
</LinearLayout>
2、小宝宝属性显示界面(activity_main.xml)具体代码如下所示:
<?xml version="1.0" encod