Android Studio设计一个计算存款利息的UI交互页面

学习目标:

  • 设计一个计算存款利息的UI交互页面

学习内容:

  1. layout文件设计
  2. Java程序编写 难点处理不同按钮对应计算不同金额不同年限的不同计算方式--复杂,孤立出一个函数来
  3. 交互

学习产出:

1在两个按钮上放监听器,本类输入

button1.setOnClickListener(this);

2文本形式获取计算

String  mystr=str. getText().toString().trim();

getText()返回的是字符串trim()去除空格

float cash=Float.parseFloat(myCash);

防止不是数字或者空的强制转化定义一下layout里面Android:inputType="number"

3弹窗提示

弹完自己消退

Toast.makeText(money.this,text:"输入不能为空",Toast.LENGTH_LONG).show();

<?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"
    android:background="@drawable/qian"
//加了一个酷炫背景

    >
    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="存款本金:"
        android:textColor="@color/white"//酷炫背景太黑了看不见字
        android:textSize="30dp"
        android:layout_marginTop="30dp"/>
    <EditText
        android:id="@+id/n1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layo
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值