【安卓】Android Studio简易计算器(实现加减乘除,整数小数运算,正数负数运算)

news2024/9/20 9:43:09

目录

前言

运算效果

一、创建一个新的项目

二、编写xml文件(计算器显示页面)

三、实现Java运算逻辑

​编辑

完整代码

xml文件代码:

 Java文件代码:

注:


前言

随着移动互联网的普及,手机应用程序已经成为人们生活中不可或缺的一部分。计算器是一类被广泛使用的应用程序之一,因此学习如何开发一款简易的计算器应用程序是学习Android Studio开发的一个很好的开始。

Android Studio是一款Google开发的用于创建安卓应用的集成开发环境(IDE), 它可以帮助开发者快速设计、开发和测试应用程序。接下来我将为大家介绍如何使用Android Studio创建一个简易的计算器应用程序。

运算效果

一、创建一个新的项目

完成上面步骤以后,点击Finish,等待加载好项目就可以继续下面的步骤了

二、编写xml文件(计算器显示页面)

打开activity_main.xml文件: res --> layout --> activity_main.xml

可以模仿主流计算器或者自己手机上面的计算器的版式来设计你的计算页面样式。

xml文件代码附到最后啦,根据自己需要自行截取复制。

然后页面显示的样子就是下面这样的:

三、实现Java运算逻辑

写好基本的显示页面后,咱就得来完成逻辑运算和点击事件了

点开MainActivity.java文件:

Java逻辑要完成的主要是如何设计点击事件以及如何实现加减乘除的逻辑

完整代码

xml文件代码:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:circularflow_angles="20"
    tools:context=".MainActivity">
<!--csdn 波士顿o泡果奶 版权所有 -->
    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/constraintLayout"
        android:layout_width="match_parent"
        android:layout_height="80dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent">

        <ImageView
            android:id="@+id/imageView"
            android:layout_width="29dp"
            android:layout_height="25dp"
            android:layout_marginTop="18dp"
            android:layout_marginEnd="10dp"
            app:layout_constraintEnd_toStartOf="@+id/imageView2"
            app:layout_constraintTop_toTopOf="parent"
            app:srcCompat="@drawable/img" />

        <ImageView
            android:id="@+id/imageView2"
            android:layout_width="32dp"
            android:layout_height="29dp"
            android:layout_marginTop="16dp"
            android:layout_marginEnd="16dp"
            app:layout_constraintEnd_toEndOf="parent"
            app:layout_constraintTop_toTopOf="parent"
            app:srcCompat="@drawable/img_1" />

        <TextView
            android:id="@+id/textView"
            android:layout_width="65dp"
            android:layout_height="41dp"
            android:layout_marginStart="16dp"
            android:layout_marginTop="7dp"
            android:text="计算"
            android:textColor="#010101"
            android:textSize="31dp"
            android:textStyle="bold"
            app:autoSizeTextType="none"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_marginStart="9dp"
            android:layout_marginTop="14dp"
            android:text="汇率"
            android:textColor="#B2B2B2"
            android:textSize="25dp"
            android:textStyle="bold"
            app:layout_constraintStart_toEndOf="@+id/textView"
            app:layout_constraintTop_toTopOf="parent" />

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="57dp"
            android:layout_height="3dp"
            android:layout_marginStart="19dp"
            android:background="#FF0101"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/textView">

        </androidx.constraintlayout.widget.ConstraintLayout>
    </androidx.constraintlayout.widget.ConstraintLayout>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:id="@+id/constraintLayout2"
        android:layout_width="410dp"
        android:layout_height="178dp"
        android:background="#FFFFFF"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/constraintLayout">

        <EditText
            android:id="@+id/editTextText2"
            android:layout_width="409dp"
            android:layout_height="83dp"
            android:layout_marginStart="2dp"
            android:layout_marginTop="76dp"
            android:ems="10"
            android:inputType="text"
            android:textSize="50sp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent" />

    </androidx.constraintlayout.widget.ConstraintLayout>

    <androidx.constraintlayout.widget.ConstraintLayout
        android:layout_width="match_parent"
        android:layout_height="466dp"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toBottomOf="@+id/constraintLayout2">

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/constraintLayout51"
            android:layout_width="409dp"
            android:layout_height="89.8dp"
            android:background="#FFFFFF"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toTopOf="parent">

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView2"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                app:cardBackgroundColor="#F2F1F1"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toStartOf="@+id/cardView"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/AC"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView12"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="18dp"
                        android:layout_marginTop="16dp"
                        android:text="AC"
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                app:cardBackgroundColor="#F2F1F1"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toStartOf="@+id/cardView3"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/cardView2"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/dl"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <ImageView
                        android:id="@+id/imageView3"
                        android:layout_width="48dp"
                        android:layout_height="30dp"
                        android:layout_marginStart="14dp"
                        android:layout_marginTop="28dp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent"
                        app:srcCompat="@drawable/img_4" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView3"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                android:background="#F2F1F1"
                app:cardBackgroundColor="#F2F1F1"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toStartOf="@+id/cardView4"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/cardView"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView14"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="16dp"
                        android:layout_marginTop="16dp"
                        android:text="+/-"
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView4"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                android:background="#F2F1F1"
                app:cardBackgroundColor="#F6E9E8"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/cardView3"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/D"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView15"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="30dp"
                        android:layout_marginTop="10dp"
                        android:text="÷ "
                        android:textSize="42sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>
        </androidx.constraintlayout.widget.ConstraintLayout>

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/constraintLayout54"
            android:layout_width="409dp"
            android:layout_height="89.8dp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/constraintLayout51">

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView2"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                app:cardBackgroundColor="#F2F1F1"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toStartOf="@+id/cardView"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/seven"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView16"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="30dp"
                        android:layout_marginTop="17dp"
                        android:text="7"
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                app:cardBackgroundColor="#F2F1F1"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toStartOf="@+id/cardView3"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/cardView2"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/eight"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView17"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="30dp"
                        android:layout_marginTop="17dp"
                        android:text="8"
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView3"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                android:background="#F2F1F1"
                app:cardBackgroundColor="#F2F1F1"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toStartOf="@+id/cardView4"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/cardView"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/nine"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView18"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="30dp"
                        android:layout_marginTop="17dp"
                        android:text="9"
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView4"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                android:background="#F2F1F1"
                app:cardBackgroundColor="#F6E9E8"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/cardView3"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/X"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView19"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="31dp"
                        android:layout_marginTop="14dp"
                        android:text="x"
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </androidx.constraintlayout.widget.ConstraintLayout>

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/constraintLayout52"
            android:layout_width="409dp"
            android:layout_height="89.8dp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/constraintLayout54">

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView2"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                app:cardBackgroundColor="#F2F1F1"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toStartOf="@+id/cardView"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/four"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView20"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="30dp"
                        android:layout_marginTop="16dp"
                        android:text="4"
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                app:cardBackgroundColor="#F2F1F1"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toStartOf="@+id/cardView3"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/cardView2"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/five"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView21"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="30dp"
                        android:layout_marginTop="16dp"
                        android:text="5"
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView3"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                android:background="#F2F1F1"
                app:cardBackgroundColor="#F2F1F1"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toStartOf="@+id/cardView4"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/cardView"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/six"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView22"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="30dp"
                        android:layout_marginTop="16dp"
                        android:text="6"
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView4"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                android:background="#F6E9E8"
                app:cardBackgroundColor="#F6E9E8"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/cardView3"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/sub"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView23"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="35dp"
                        android:layout_marginTop="16dp"
                        android:text="-"
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </androidx.constraintlayout.widget.ConstraintLayout>

        <androidx.constraintlayout.widget.ConstraintLayout
            android:id="@+id/constraintLayout53"
            android:layout_width="409dp"
            android:layout_height="89.8dp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/constraintLayout52">

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView2"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                app:cardBackgroundColor="#F2F1F1"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toStartOf="@+id/cardView"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/one"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView24"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="30dp"
                        android:layout_marginTop="16dp"
                        android:text="1"
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                app:cardBackgroundColor="#F2F1F1"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toStartOf="@+id/cardView3"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/cardView2"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/two"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView25"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="30dp"
                        android:layout_marginTop="16dp"
                        android:text="2"
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView3"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                android:background="#F2F1F1"
                app:cardBackgroundColor="#F2F1F1"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toStartOf="@+id/cardView4"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/cardView"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/three"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView26"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="30dp"
                        android:layout_marginTop="16dp"
                        android:text="3"
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView4"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                android:background="#F2F1F1"
                app:cardBackgroundColor="#F6E9E8"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/cardView3"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/add"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView27"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="30dp"
                        android:layout_marginTop="16dp"
                        android:text="+"
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </androidx.constraintlayout.widget.ConstraintLayout>

        <androidx.constraintlayout.widget.ConstraintLayout
            android:layout_width="409dp"
            android:layout_height="89.8dp"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintTop_toBottomOf="@+id/constraintLayout53">

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView2"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                app:cardBackgroundColor="#F2F1F1"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toStartOf="@+id/cardView"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toStartOf="parent"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/yu"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView28"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="27dp"
                        android:layout_marginTop="17dp"
                        android:text="%"
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                app:cardBackgroundColor="#F2F1F1"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toStartOf="@+id/cardView3"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/cardView2"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/zero"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView29"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="30dp"
                        android:layout_marginTop="17dp"
                        android:text="0"
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView3"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                android:background="#F2F1F1"
                app:cardBackgroundColor="#F2F1F1"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toStartOf="@+id/cardView4"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/cardView"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/point"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView30"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="36dp"
                        android:layout_marginTop="17dp"
                        android:text="."
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent" />

            <androidx.cardview.widget.CardView
                android:id="@+id/cardView4"
                android:layout_width="80dp"
                android:layout_height="80dp"
                android:layout_marginTop="5dp"
                android:background="#F2F1F1"
                app:cardBackgroundColor="#F85955"
                app:cardCornerRadius="45dp"
                app:layout_constraintEnd_toEndOf="parent"
                app:layout_constraintHorizontal_bias="0.5"
                app:layout_constraintStart_toEndOf="@+id/cardView3"
                app:layout_constraintTop_toTopOf="parent">

                <androidx.constraintlayout.widget.ConstraintLayout
                    android:id="@+id/equal"
                    android:layout_width="match_parent"
                    android:layout_height="match_parent">

                    <TextView
                        android:id="@+id/textView32"
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_marginStart="31dp"
                        android:layout_marginTop="16dp"
                        android:text="="
                        android:textSize="35sp"
                        app:layout_constraintStart_toStartOf="parent"
                        app:layout_constraintTop_toTopOf="parent" />
                </androidx.constraintlayout.widget.ConstraintLayout>
            </androidx.cardview.widget.CardView>

            <androidx.constraintlayout.widget.ConstraintLayout
                android:layout_width="match_parent"
                android:layout_height="match_parent" />
        </androidx.constraintlayout.widget.ConstraintLayout>
    </androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>

 Java文件代码:

import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;

import android.os.Bundle;
import android.view.View;
import android.widget.EditText;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {

    private  StringBuilder show=new StringBuilder();
    private  ArrayList calculate_equation;
    private  int signal=0;//为0 时表示刚输入状态;为1时表示当前在输出结果上继续输入
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        show=new StringBuilder();
        calculate_equation=new ArrayList<>();
//李木
        ConstraintLayout AC = findViewById(R.id.AC);
        ConstraintLayout Divide = findViewById(R.id.D);
        ConstraintLayout Multiplication = findViewById(R.id.X);
        ConstraintLayout Sub = findViewById(R.id.sub);
        ConstraintLayout Add = findViewById(R.id.add);
        ConstraintLayout Equal = findViewById(R.id.equal);
        ConstraintLayout Point = findViewById(R.id.point);
        ConstraintLayout one = findViewById(R.id.one);
        ConstraintLayout two = findViewById(R.id.two);
        ConstraintLayout three = findViewById(R.id.three);
        ConstraintLayout four = findViewById(R.id.four);
        ConstraintLayout five = findViewById(R.id.five);
        ConstraintLayout six = findViewById(R.id.six);
        ConstraintLayout seven = findViewById(R.id.seven);
        ConstraintLayout eight = findViewById(R.id.eight);
        ConstraintLayout nine = findViewById(R.id.nine);
        ConstraintLayout zero = findViewById(R.id.zero);
        EditText result=findViewById(R.id.editTextText2);

        AC.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                show.delete(0,show.length());
                show.append("");
                result.setText(show);
                result.setSelection(result.getText().length());
                signal=0;
            }
        });
        zero.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v){
                if(!(show.toString().equals("0"))){
                    if(signal==0){
                        show.append("0");
                        result.setText(show);
                        result.setSelection(result.getText().length());
                    }else{
                        show.delete(0,show.length());
                        show.append("0");
                        result.setText(show);
                        result.setSelection(result.getText().length());
                        signal=0;
                    }
                }
            }
        });
        one.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(signal==0){
                    show.append("1");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                }else{
                    show.delete(0,show.length());
                    show.append("1");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                    signal=0;
                }
            }
        });
        two.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(signal==0){
                    show.append("2");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                }else{
                    show.delete(0,show.length());
                    show.append("2");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                    signal=0;
                }
            }
        });
        three.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(signal==0){
                    show.append("3");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                }else{
                    show.delete(0,show.length());
                    show.append("3");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                    signal=0;
                }
            }
        });
        four.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(signal==0){
                    show.append("4");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                }else{
                    show.delete(0,show.length());
                    show.append("4");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                    signal=0;
                }
            }
        });
        five.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(signal==0){
                    show.append("5");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                }else{
                    show.delete(0,show.length());
                    show.append("5");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                    signal=0;
                }
            }
        });
        six.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(signal==0){
                    show.append("6");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                }else{
                    show.delete(0,show.length());
                    show.append("6");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                    signal=0;
                }
            }
        });
        seven.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(signal==0){
                    show.append("7");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                }else{
                    show.delete(0,show.length());
                    show.append("7");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                    signal=0;
                }
            }
        });
        eight.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(signal==0){
                    show.append("8");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                }else{
                    show.delete(0,show.length());
                    show.append("8");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                    signal=0;
                }
            }
        });
        nine.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(signal==0){
                    show.append("9");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                }else{
                    show.delete(0,show.length());
                    show.append("9");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                    signal=0;
                }
            }
        });


        Point.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(signal==0){
                    String a=show.toString();
                    if(a.equals("")){
                        show.append(".");
                        result.setText(show);
                        result.setSelection(result.getText().length());
                    }else{
                        int i;
                        char t='0';
                        for(i=a.length();i>0;i--){
                            t=a.charAt(i-1);
                            if(t=='.'||t=='+'||t=='-'||t=='*'||t=='/')
                                break;
                        }
                        if(i==0){
                            show.append(".");
                            result.setText(show);
                            result.setSelection(result.getText().length());
                        }else if(t=='+'||t=='-'||t=='*'||t=='/'){
                            show.append(".");
                            result.setText(show);
                            result.setSelection(result.getText().length());
                        }
                    }
                }else{
                    show.delete(0,show.length());
                    show.append(".");
                    result.setText(".");
                    result.setSelection(result.getText().length());
                    signal=0;
                }
            }
        });

        Equal.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //判断用户是否输入了内容
                if(!show.toString().equals("")){
                    signal=1;
                    char temp=show.charAt(show.length()-1);
                    if(show.charAt(0)=='-')
                        show.insert(0,"0");
                    if(temp=='+'||temp=='-')
                        show.append("0");
                    if(temp=='*'||temp=='/')
                        show.append("1");
                    StringBuilder temp1=new StringBuilder();
                    for(int i=0;i<show.length();i++){
                        if(show.charAt(i)>='0'&&show.charAt(i)<='9'||show.charAt(i)=='.'){
                            temp1.append(String.valueOf(show.charAt(i)));
                        }else if(show.charAt(i)=='N'){
                            calculate_equation.add("NaN");
                            i=i+2;
                        }else if(show.charAt(i)=='∞'){
                            calculate_equation.add("∞");
                        }
                        else
                        {
                            if(temp1.length()!=0){
                                calculate_equation.add(temp1.toString());
                                temp1.delete(0,temp1.length());
                            }
                            calculate_equation.add(String.valueOf(show.charAt(i)));
                        }
                    }
                    if(temp1.length()!=0){
                        calculate_equation.add(temp1.toString());
                    }
                    calculate_equation.add("#");
                    String temp8=calculate(calculate_equation);
                    result.setText(temp8);
                    result.setSelection(result.getText().length());
                    show.delete(0,show.length());
                    calculate_equation.clear();
                    show.append(temp8);
                }
            }
        });
        Add.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //判断用户是否输入了内容
                if(!(show.toString().equals(""))) {
                    signal=0;
                    char temp=show.charAt(show.length()-1);
                    if(temp=='+'||temp=='-'||temp=='*'||temp=='/')
                    {
                        show.deleteCharAt(show.length()-1);
                        show.append("+");
                    }
                    else
                        show.append("+");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                }
            }
        });
        Sub.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //判断用户是否输入了内容
                if(!(show.toString().equals(""))) {
                    signal=0;
                    char temp=show.charAt(show.length()-1);
                    if(temp=='+'||temp=='-'||temp=='*'||temp=='/')
                    {
                        show.deleteCharAt(show.length()-1);
                        show.append("-");
                    }
                    else
                        show.append("-");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                }
            }
        });

        Multiplication.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //判断用户是否输入了内容
                if(!(show.toString().equals(""))) {
                    signal=0;
                    char temp=show.charAt(show.length()-1);
                    if(temp=='+'||temp=='-'||temp=='*'||temp=='/')
                    {
                        show.deleteCharAt(show.length()-1);
                        show.append("*");
                    }
                    else
                        show.append("*");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                }
            }
        });

        Divide.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                //判断用户是否输入了内容
                if(!(show.toString().equals(""))) {
                    signal=0;
                    char temp=show.charAt(show.length()-1);
                    if(temp=='+'||temp=='-'||temp=='*'||temp=='/')
                    {
                        show.deleteCharAt(show.length()-1);
                        show.append("/");
                    }
                    else
                        show.append("/");
                    result.setText(show);
                    result.setSelection(result.getText().length());
                }
            }
        });
    }
    protected boolean operatorPriorityCompare(char operator1,char operator2)
    {
        int o1=0;
        int o2=0;
        switch (operator1){
            case '+':{o1=0;break;}
            case '-':{o1=0;break;}
            case '*':{o1=1;break;}
            case '/':{o1=1;break;}
        }
        switch (operator2){
            case '+':{o2=0;break;}
            case '-':{o2=0;break;}
            case '*':{o2=1;break;}
            case '/':{o2=1;break;}
        }
        if(o1<=o2)
        {
            return false;
        }
        else
            return true;
    }
    //相加
    public static Double Add(Double d1,Double d2) {
        if(d1==Double.NEGATIVE_INFINITY||d1==Double.POSITIVE_INFINITY||d2==Double.NEGATIVE_INFINITY||d2==Double.POSITIVE_INFINITY){
            return d1+d2;
        }
        if(String.valueOf(d1).equals("NaN")||String.valueOf(d1).equals("NaN")){
            return d1+d2;
        }
        BigDecimal b1 = new BigDecimal(Double.toString(d1));
        BigDecimal b2 = new BigDecimal(Double.toString(d2));
        return b1.add(b2).doubleValue();
    }
    //相减
    public static Double Sub(Double d1,Double d2){
        if(d1==Double.NEGATIVE_INFINITY||d1==Double.POSITIVE_INFINITY||d2==Double.NEGATIVE_INFINITY||d2==Double.POSITIVE_INFINITY){
            return d1-d2;
        }
        if(String.valueOf(d1).equals("NaN")||String.valueOf(d1).equals("NaN")){
            return d1-d2;
        }
        if(String.valueOf(d1).equals("NaN")||String.valueOf(d1).equals("NaN")){
            return d1*d2;
        }
        BigDecimal b1=new BigDecimal(Double.toString(d1));
        BigDecimal b2=new BigDecimal(Double.toString(d2));
        return b1.subtract(b2).doubleValue();
    }
    //相乘
    public static Double Mul(Double d1,Double d2){
        if(d1==Double.NEGATIVE_INFINITY||d1==Double.POSITIVE_INFINITY||d2==Double.NEGATIVE_INFINITY||d2==Double.POSITIVE_INFINITY){
            return d1*d2;
        }
        if(String.valueOf(d1).equals("NaN")||String.valueOf(d1).equals("NaN")){
            return d1*d2;
        }
        BigDecimal b1=new BigDecimal(Double.toString(d1));
        BigDecimal b2=new BigDecimal(Double.toString(d2));
        return b1.multiply(b2).setScale(8).doubleValue();
    }
    //相除
    public static Double Div(Double d1,Double d2){
        if(d1==Double.NEGATIVE_INFINITY||d1==Double.POSITIVE_INFINITY||d2==Double.NEGATIVE_INFINITY||d2==Double.POSITIVE_INFINITY){
            return d1/d2;
        }
        if(String.valueOf(d1).equals("NaN")||String.valueOf(d1).equals("NaN")){
            return d1/d2;
        }
        if(d1==0.0&&d2==0.0){
            return Double.NaN;
        }
        if(d2==0.0){
            return d1/d2;
        }
        BigDecimal b1=new BigDecimal(Double.toString(d1));
        BigDecimal b2=new BigDecimal(Double.toString(d2));
        return b1.divide(b2,8,BigDecimal.ROUND_HALF_UP).doubleValue();
    }
    protected String calculate(ArrayList equation){
        Double temp2;
        Double temp3;
        Double result;
        List operator=new ArrayList();
        List<Double> operand=new ArrayList();
        for(int i=0;i<equation.size();i++)
        {
            String temp4=(String) equation.get(i);
            if(temp4.equals("+")||temp4.equals("-")||temp4.equals("*")||temp4.equals("/"))
            {
                if(operator.size()>0)
                {
                    String temp5=operator.get(operator.size()-1).toString();
                    while(!(operatorPriorityCompare(temp4.charAt(0),temp5.charAt(0)))&&operator.size()>0)
                    {
                        operator.remove(operator.size()-1);
                        temp3=operand.get(operand.size()-1);
                        operand.remove(operand.size()-1);
                        temp2=operand.get(operand.size()-1);
                        operand.remove(operand.size()-1);
                        switch (temp5.charAt(0)){
                            case '+':{result=Add(temp2,temp3);operand.add(result);break;}
                            case '-':{result=Sub(temp2,temp3);operand.add(result);break;}
                            case '*':{result=Mul(temp2,temp3);operand.add(result);break;}
                            case '/':{result=Div(temp2,temp3);operand.add(result);break;}
                        }
                        if(operator.size()>0)
                        {
                            temp5=operator.get(operator.size()-1).toString();
                        }
                        else
                            break;
                    }
                    operator.add(temp4);
                }
                else
                    operator.add(temp4);
            }
            else if(temp4.equals("#"))
            {
                while(operator.size()>0)
                {
                    String temp6=(String)operator.get(operator.size()-1);
                    operator.remove(operator.size()-1);
                    temp3=operand.get(operand.size()-1);
                    operand.remove(operand.size()-1);
                    temp2=operand.get(operand.size()-1);
                    operand.remove(operand.size()-1);
                    switch (temp6.charAt(0)){
                        case '+':{result=Add(temp2,temp3);operand.add(result);break;}
                        case '-':{result=Sub(temp2,temp3);operand.add(result);break;}
                        case '*':{result=Mul(temp2,temp3);operand.add(result);break;}
                        case '/':{result=Div(temp2,temp3);operand.add(result);break;}
                    }
                }
            }
            else
            {
                if(temp4.equals("NaN")){
                    operand.add(Double.NaN);
                }else if(temp4.equals("∞")){
                    operand.add(Double.POSITIVE_INFINITY);
                }else{
                    operand.add(Double.parseDouble(temp4));
                }
            }
        }
        if(operand.get(0)==Double.NEGATIVE_INFINITY) return "-∞";
        if(operand.get(0)==Double.POSITIVE_INFINITY) return "∞";
        return operand.get(0).toString();
    }
}

/*
* csdn 波士顿o泡果奶 版权所有 */

注:

xml文件中有一些图片,若完全粘贴xml代码,可将图片换成自己的图片,图片资源放到哪里,这里我就不多说了,可以参考下面的那些博客安卓studio图片资源放到哪里- CSDN搜索icon-default.png?t=N7T8https://so.csdn.net/so/search?q=%E5%AE%89%E5%8D%93studio%E5%9B%BE%E7%89%87%E8%B5%84%E6%BA%90%E6%94%BE%E5%88%B0%E5%93%AA%E9%87%8C&t=&u=&urw=

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1953591.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

fetchApi === 入门篇

目录 fetch 基本认知 fetch 如何使用 Response对象&#xff08;了解&#xff09; 常见属性 常见方法 fetch 配置参数 fetch发送post请求 fetch 函数封装 fetch 实战 - 图书管理案例 渲染功能 添加功能 删除数据 完整代码 fetch 基本认知 思考&#xff1a; 以前开发…

PCIe总线-Linux内核PCIe软件框架分析(十一)

1.简介 Linux内核PCIe软件框架如下图所示&#xff0c;按照PCIe的模式&#xff0c;可分为RC和EP软件框架。RC的软件框架分为五层&#xff0c;第一层为RC Controller Driver&#xff0c;和RC Controller硬件直接交互&#xff0c;不同的RC Controller&#xff0c;其驱动实现也不相…

永结无间Ⅰ--基于 LLM 的 AGI

在过去几周&#xff0c;传奇人物 Francois Chollet 发起的ARC 挑战引起了不小的轰动。这项挑战让很多 AI 研究人员感到困惑&#xff0c;它表明了所有 AI 系统都存在泛化能力不足的问题。ARC 上上一次 SOTA AI 的准确率约为 34%&#xff0c;而在同一挑战中&#xff0c;Mechanica…

【React】Context机制跨层传递数据详解

文章目录 一、React Context的概念二、创建和使用Context1. 创建Context2. 使用Provider提供数据3. 使用Consumer获取数据 三、使用useContext Hook四、动态更新Context值五、Context的实际应用场景1. 主题切换2. 用户认证状态 六、注意事项 在开发React应用时&#xff0c;我们…

【C语言】深入探讨数组传参

一、数组传参简介 在C语言中&#xff0c;数组传参是一个常见的操作&#xff0c;尤其是在处理大量数据或需要多次访问相同数据集时。理解如何传递数组以及这些方法之间的差异是编写高效和安全代码的关键。在这篇博客中&#xff0c;我们将详细讨论C语言中数组传参的几种常见方法&…

【网络】应用层协议(自定义协议)(序列和反序列化)

应用层协议&#xff08;自定义协议&#xff09;&#xff08;序列和反序列化&#xff09; 一、引言--应用层的使用二、应用层1、网络版本计算器&#xff08;1&#xff09;协议定制和序列反序列化&#xff08;2&#xff09;网络版计算器协议定制i、封装有效载荷&#xff08;默认上…

数据结构——单链表OJ题(上)

目录 一、移除链表元素 1.思路 2.注意 3.解题 二、反转链表 思路1&#xff1a;三指针翻转法 &#xff08;1&#xff09;注意 &#xff08;2&#xff09;解题 思路2&#xff1a;头插法 &#xff08;1&#xff09;注意 &#xff08;2&#xff09;解题 三、链表的中间结…

depcheck 前端依赖检查

介绍 depcheck 是一款用于检测项目中 未使用依赖项 的工具。 depcheck 通过扫描项目文件&#xff0c;帮助你找出未被引用的依赖&#xff0c;从而优化项目。 优势&#xff1a; 简单易用: 仅需几个简单的命令&#xff0c;就能够扫描并列出未使用的依赖项&#xff0c;让你快速了…

The Schematic workflow failed. See above.

在使用 ng new 新建Angular项目的时候会报一个错误&#xff1a;The Schematic workflow failed. See above. 解决办法&#xff1a; 只需要在后面加上 --skip-install 参数&#xff0c;就不会报错了。 ng new myapp --skip-install

打工人电脑里都需要的远程控制软件有哪些?这4款不能错过

不巧前几天台风&#xff0c;实在没办法到公司&#xff0c;但是项目还得继续&#xff0c;这时候远程控制电脑的技巧可谓是帮了我大忙了。不知道平常的你偶尔会不会也需要远程控制电脑的操作&#xff0c;如果有就继续看下去吧。 1.向日魁远程控制 直通车>>https://down.o…

AJAX-Promise 详解

(创作不易&#xff0c;感谢有你&#xff0c;你的支持&#xff0c;就是我前行的最大动力&#xff0c;如果看完对你有帮助&#xff0c;请留下您的足迹&#xff09; 目录 前言 一、Promise基本概念 1.1 定义 1.2 状态 1.3 构造函数 二、Promise基本用法 2.1 then() 2.2 ca…

ThinkPHP一对一关联模型的运用(ORM)

一、序言 最近在写ThinkPHP关联模型的时候一些用法总忘&#xff0c;我就想通过写博客的方式复习和整理下一些用法。 具体版本&#xff1a; topthink/framework&#xff1a;6.1.4topthink/think-orm&#xff1a;2.0.61 二、实例应用 1、一对一关联 1.1、我先设计了两张表&#x…

根据题意写出完整的css,html和js代码【购物车模块页面及功能实现】

🏆本文收录于《CSDN问答解惑-专业版》专栏,主要记录项目实战过程中的Bug之前因后果及提供真实有效的解决方案,希望能够助你一臂之力,帮你早日登顶实现财富自由🚀;同时,欢迎大家关注&&收藏&&订阅!持续更新中,up!up!up!! 问题描述 根据题意写出完…

基于微信小程序+SpringBoot+Vue的社区超市管理系统(带1w+文档)

基于微信小程序SpringBootVue的社区超市管理系统(带1w文档) 基于微信小程序SpringBootVue的社区超市管理系统(带1w文档) 为了让商品信息的管理模式进行升级&#xff0c;也为了更好的维护商品信息&#xff0c;社区超市管理系统的开发运用就显得很有必要&#xff0c;因为它不仅可…

C# 植物大战僵尸

Winform 版本开发 高效率、流畅植物大战僵尸 git地址&#xff1a;冯腾飞/植物大战僵尸

go语言day19 使用git上传包文件到github Gin框架入门

git分布式版本控制系统_git切换head指针-CSDN博客 获取请求参数并和struct结构体绑定_哔哩哔哩_bilibili &#xff08;gin框架&#xff09; GO: 引入GIn框架_go 引入 gin-CSDN博客 使用git上传包文件 1&#xff09;创建一个github账户&#xff0c;进入Repositories个人仓…

我在百科荣创企业实践——简易函数信号发生器(6)

对于高职教师来说,必不可少的一个任务就是参加企业实践。这个暑假,本人也没闲着,报名参加了上海市电子信息类教师企业实践。7月8日到13日,有幸来到美丽的泉城济南,远离了上海的酷暑,走进了百科荣创科技发展有限公司。在这短短的一周时间里,我结合自己的教学经验和企业的…

buu做题(8)

[安洵杯 2019]easy_web 查看源代码可以发现一长串的base64编码 就是页面上的一张图片 回到原页面,url上面也有一些奇怪的参数 经过两次base64和一次hex 解密后得到 555.png 应该就是包含着页面上的这张图片 然后尝试将index.php 按照这样的方式编码, 看看能不能包含到 TmprMl…

后端解决跨域(Cross-Origin Resource Sharing)(三种方式)

注解CrossOrigin 控制层的类上或者方法上加注解CrossOrigin 实现接口并重写方法 Configuration public class CorsConfig implements WebMvcConfigurer {Overridepublic void addCorsMappings(CorsRegistry registry) {// 设置允许跨域的路径registry.addMapping("/**&qu…

算法通关:006_4二分查找:寻找数组中的峰值

文章目录 描述主要代码全部代码运行结果总结 二分法不一定只能用在有序数组中。 描述 leetcode&#xff1a;162 主要代码 //二分法查找峰值public static int findPeakElement(int[] arr){if (arr.length 1){//randomArray()不会出现arr null的情况return 0;}//先检查 0…