Activity的数据跳转回传案例——装备选择案例

本文通过一个装备选择的案例展示Android中Activity的数据跳转和回传过程。当从主界面点击购买装备按钮进入装备界面,选择装备后返回,主界面的进度条和数值会相应更新。案例代码包括activity_main.xml布局文件和MainActivity的实现。
摘要由CSDN通过智能技术生成

用装备选择案例来给大家演示一下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"
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值