用装备选择案例来给大家演示一下Activity的数据跳转回传
效果图:
点击购买装备按钮跳转到装备界面,点击装备后返回主界面然后进度条和数值会发生变化。
首先把小宝宝的图片给大家
当然图片无所谓了,可以根据自己个性选择。
接下来是Android模式下的部署
activity_main.xml(主界面)下的代码
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/xiaobaobao"
android:layout_gravity="center_horizontal"
android:layout_marginTop="45dp"
/>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="主人,快给小宝宝买装备吧"
android:textSize="18sp"
android:gravity="center_horizontal"/>
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="45dp">
<TableRow
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<TextView
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:text="生命值:"
/>
<ProgressBar
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="0dp"
android:layout_weight="3"
android:layout_marginLeft="20dp"
android:layout_marginTop="5dp"
android:layout_height="wrap_content"
android:id="@+id/progressBar" />
<TextView
android:id="@+id/tv1"