Android简单计算器

article/2025/10/24 0:49:51

文章目录

    • 一、案列
    • 一、步骤
      • 1、activity_main.xml
      • 2、colors.xml
      • 3、strings.xml
      • 4、图片

一、案列

实现简易计算器
在这里插入图片描述

一、步骤

线性布局实现计算器,一个线性垂直布局里嵌套多个线性水平布局,插入文本框,编辑框,按钮多个控件,通过layout_weight设置权重,调整位置。
在这里插入图片描述

1、activity_main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"xmlns:app="http://schemas.android.com/apk/res-auto"android:layout_width="match_parent"android:layout_height="match_parent"android:background="@drawable/lufei"android:orientation="vertical" ><TextViewandroid:id="@+id/textView1"android:layout_width="wrap_content"android:layout_height="wrap_content"android:layout_gravity="center"android:text="@string/hello"android:textColor="@color/color"android:textSize="50dp"/><EditTextandroid:id="@+id/edittext"android:layout_width="match_parent"android:layout_height="50dp"android:text="EditText"/>	<LinearLayoutandroid:layout_weight="1"android:layout_width="match_parent"android:layout_height="0dp" ><Buttonandroid:id="@+id/buttonce"android:layout_width="wrap_content"android:layout_height="match_parent"android:text="CE"android:layout_weight="1"android:layout_margin="4dp"android:textSize="30dp"></Button><Buttonandroid:id="@+id/buttoncjia"android:layout_width="wrap_content"android:layout_height="match_parent"android:text="+"android:layout_weight="1"android:layout_margin="4dp"android:textSize="30dp"></Button><Buttonandroid:id="@+id/buttoncecheng"android:layout_width="wrap_content"android:layout_height="match_parent"android:text="*"android:layout_weight="1"android:layout_margin="4dp"android:textSize="30dp"></Button><Buttonandroid:id="@+id/buttoncec"android:layout_width="wrap_content"android:layout_height="match_parent"android:text="c"android:layout_weight="1"android:layout_margin="4dp"android:textSize="30dp"></Button></LinearLayout><LinearLayoutandroid:layout_weight="1"android:layout_width="match_parent"android:layout_height="0dp"  ><Buttonandroid:id="@+id/button7"android:layout_width="wrap_content"android:layout_height="match_parent"android:layout_weight="1"android:layout_margin="4dp"android:textSize="30dp"android:text="7" /><Buttonandroid:id="@+id/button8"android:layout_width="wrap_content"android:layout_height="match_parent"android:layout_weight="1"android:layout_margin="4dp"android:textSize="30dp"android:text="8" /><Buttonandroid:id="@+id/button9"android:layout_width="wrap_content"android:layout_height="match_parent"android:layout_weight="1"android:layout_margin="4dp"android:textSize="30dp"android:text="9" /><Buttonandroid:id="@+id/button12"android:layout_width="wrap_content"android:layout_height="match_parent"android:layout_weight="1"android:layout_margin="4dp"android:textSize="30dp"android:text="+" /></LinearLayout><LinearLayoutandroid:layout_weight="1"android:layout_width="match_parent"android:layout_height="0dp"  ><Buttonandroid:id="@+id/button4"android:layout_width="wrap_content"android:layout_height="match_parent"android:layout_weight="1"android:layout_margin="4dp"android:textSize="30dp"android:text="4" /><Buttonandroid:id="@+id/button5"android:layout_width="wrap_content"android:layout_height="match_parent"android:layout_weight="1"android:layout_margin="4dp"android:textSize="30dp"android:text="5" /><Buttonandroid:id="@+id/button6"android:layout_width="wrap_content"android:layout_height="match_parent"android:layout_weight="1"android:layout_margin="4dp"android:textSize="30dp"android:text="6" /><Buttonandroid:id="@+id/button13"android:layout_width="wrap_content"android:layout_height="match_parent"android:layout_weight="1"android:layout_margin="4dp"android:textSize="30dp"android:text="-" /></LinearLayout><LinearLayoutandroid:layout_weight="1"android:layout_width="match_parent"android:layout_height="0dp" ><Buttonandroid:id="@+id/button1"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:layout_margin="4dp"android:textSize="30dp"android:text="1" /><Buttonandroid:id="@+id/button2"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:layout_margin="4dp"android:textSize="30dp"android:text="2" /><Buttonandroid:id="@+id/button3"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:layout_margin="4dp"android:textSize="30dp"android:text="3" /><ImageButtonandroid:id="@+id/button14"android:layout_width="0dp"android:layout_height="103dp"android:layout_marginTop="10dp"android:layout_marginRight="4dp"android:layout_marginLeft="4dp"android:layout_weight="1"android:background="#2B40B5"android:scaleType="fitXY"android:src="@drawable/sqrt" /></LinearLayout><LinearLayoutandroid:layout_weight="1"android:layout_width="match_parent"android:layout_height="0dp"  ><Buttonandroid:id="@+id/button0"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="2"android:layout_margin="4dp"android:textSize="30dp"android:text="0" /><Buttonandroid:id="@+id/button10"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:layout_margin="4dp"android:textSize="30dp"android:text="." /><Buttonandroid:id="@+id/button11"android:layout_width="0dp"android:layout_height="match_parent"android:layout_weight="1"android:layout_margin="4dp"android:textSize="30dp"android:text="=" /></LinearLayout>
</LinearLayout>

2、colors.xml

colors.xml 定义颜色

<?xml version="1.0" encoding="utf-8"?>
<resources><color name="purple_200">#FFBB86FC</color><color name="purple_500">#FF6200EE</color><color name="purple_700">#FF3700B3</color><color name="teal_200">#FF03DAC5</color><color name="teal_700">#FF018786</color><color name="black">#FF000000</color><color name="white">#FFFFFFFF</color><color name="color">#3F51B5</color>
</resources>

3、strings.xml

strings.xml 定义字符串

<resources><string name="app_name">Han qian</string><string name="hello">计算器</string>
</resources>

4、图片

lufei.png
sqrt.png
liupick.png
在这里插入图片描述


http://chatgpt.dhexx.cn/article/BDV81nOe.shtml

相关文章

19:简单计算器

原题链接 总时间限制: 1000ms 内存限制: 65536kB 描述 一个最简单的计算器&#xff0c;支持, -, *, / 四种运算。仅需考虑输入输出为整数的情况&#xff0c;数据和运算结果不会超过int表示的范围。 输入 输入只有一行&#xff0c;共有三个参数&#xff0c;其中第1、2个参数…

python制作简单计算器

​ 做一个计算器&#xff0c;这是我们想要的效果。 1、准备工作 导入time、tqdm、math库 from tqdm import* from time import* from math import*2、开始 添加一个重复循环并添加变量s while True:#清屏print(\033c)while True:#如果用法输入的是str类型将打印输入错误&…

JavaScript实现简单计算器

一、两个输入框输入数值计算 步骤 1、编写html代码&#xff0c;实现计算器页面视图效果 2、编写js&#xff0c;实现点击输入数字和符号输出结果 1、编写html 1.1定义两个输入框和一个隐藏框。 1.2定义加减乘除四个按钮&#xff0c;并在里面设置一个单击事件onclick&#…

Java编写简单计算器

本文用Java的swing来实现一个简单计算器&#xff0c;主要内容为图形用户界面GUI的实现以及运算表达式核心算法的设计编写。 程序运行环境为Windows10 &#xff0c;编译环境为IntelliJ IDEA Community Edition 2022.2.3 一、具体功能&#xff1a; 1、&#xff1a;输入&#x…

项目一:简单计算器的实现

项目概述 1.1项目目标和主要内容 学习图形界 面的设计&#xff0c;利用 MFC 应用程序&#xff08;Java swing 或 QT 框架&#xff0c;或 C#&#xff09;创建基于对话框的应用程序&#xff0c;添加按钮、编辑框等控件&#xff1b; 能通过设计的按钮控件输入并实现简单算术运算&a…

【C语言】实现简易计算器

目录 1.实现逻辑 2.运行过程 3.优化前代码分析 主函数 计算函数 4.优化后代码分析 主函数 计算方法函数 输入操作数的函数 5.完整代码展示 1.实现逻辑 实现一个简易的计算器&#xff0c;可以计算两个整数的加减乘除 2.运行过程 3.优化前代码分析 主函数 int main()…

java工作流引擎,roadflow(一个强大的工作流引擎)

JAVA工作流引擎(J-RoadFlow) J-RoadFlow工作流平台是知名的.NET工作流引擎RoadFlow的JAVA移植版。该工作流平台由从事多年OA和工作流实施及开发的团队研发&#xff0c; 采用最简单的SM架构实现大中小企业中日常复杂业务流程审批。JAVA版不仅仅是.NET版本的移植&#xff0c;从架…

Easy-Flows - Java的简单愚蠢的工作流引擎

The simple, stupid workflow engine for Java 源代码名称&#xff1a;easy-flows源代码网址&#xff1a;http://www.github.com/j-easy/easy-flowseasy-flows 源代码文档easy-flows 源代码下载 Git URL git://www.github.com/j-easy/easy-flows.git Git Clone 代码到本地 g…

Flowable工作流引擎

Flowable工作流引擎 Flowable-基础篇(根据BV1Pb4y1p7Ku整理) 一、简介 Flowable是BPMN的一个基于java的软件实现&#xff0c;不过Flowable不仅仅包括BPMN&#xff0c;还有DMN决策表和CMMN Case管理引擎&#xff0c;并且有自己的用户管理、微服务API等一系列功能&#xff0c;…

Java工作流引擎

Java工作流引擎有很多&#xff0c;有免费和商业的 主流免费&#xff1a;Activiti和Flowable Activiti和Flowable都是来自于一个叫JBPM的开源工作流。在早期Jboss发行JBPM4的时候&#xff0c;因为合作伙伴关系闹的不开心。于是其中一个核心人员离职。加入了Alfresco(Activiti所…

工作流引擎技术选型

一、主流开源框架介绍 1、工作流相关文档 1.Camunda 官方文档&#xff1a;https://camunda.com/ 中文文档&#xff1a;介绍 | docs.camunda.org 2.Activiti 官方文档&#xff1a;https://www.activiti.org/ 中文文档&#xff1a;[activiti6用户手册 3.Snaker 官方文档&…

Java开源工作流引擎 介绍

Java开源工作流引擎 http://www.open-open.com/08.htm 身为拿来主义者&#xff0c; 很好的吸取经验才是我们的目的&#xff01; Willow 由Huihoo Power开发详细可到其中文主页查看。 更多Willow信息 OpenWFE OpenWFE是一个开放源码的Java工作流引擎。它是一个完整的业务处理…

最近进行的一次技术选型(工作流引擎)及相关知识介绍

前言 最近有个新项目&#xff0c;需要实现类似工作流引擎的效果&#xff0c;如果不知道是啥&#xff0c;看完本文就懂了。 公司内其实也有些自研的&#xff0c;可能就是不像开源的这些那样&#xff0c;还支持这个那个规范&#xff0c;都是基于需求定制开发的&#xff0c;扩展…

java工作流引擎(j-roadflow)快速入门教程

使用j-roadflow java工作流引擎创建一个流程分为两个步骤&#xff0c;创建表单和创建流程。 一、创建表单。 在流程管理--表单管理下点新建表单即开始创建一个新的表单&#xff1a; 点击之后打开表单设计器并弹出表单属性设置&#xff1a; 表单名称&#xff1a;为您新建的表单…

为什么使用工作流引擎,什么是工作流引擎,工作流引擎选型以及如何使用

文章目录 为什么使用工作流引擎&#xff1f;不使用工作流存在以下问题工作流优缺点 什么是工作流引擎尝试自己构建工作流引擎有哪些选型方案呢基于bpmn标准进行流程定义国产自定义 如何使用SnakerFlow工作流以请假流程来看下数据库中数据流转情况初始状态员工发起请假申请 常见…

工作流引擎

1 绪论 【社会上的需求.】 1.1 课题的研究背景 工作流的概念起源于生产组织和办公自动化领域。它是针对日常工作中具有固定程序的活动而提出得一个概念。它的主要特点是使处理过程自动化&#xff0c;通过将工作分解成定义良好的任务、角色&#xff0c;按照一定的规则和过程来执…

LeaRun.Java工作流引擎 快速开发业务流程

工作流引擎是用来开发工作流转的框架。作为应用系统的一部分&#xff0c;能根据角色、分工和条件的不同决定信息传递路由、内容等级等核心解决方案&#xff0c;包含组织结构、流程、节点、转向规则等。 而低代码开发框架&#xff0c;是能够解决一个可以直接在后台配置就可以开…

IBPS java工作流引擎介绍

java工作流引擎是什么&#xff1f;看了这篇文章&#xff0c;相信80%的人都会明白的。IBPS低代码开发平台是近些年流辰信息的主打产品&#xff0c;实践证明&#xff0c;该产品推向市场后&#xff0c;得到了企业信息化部门、各高校、电力等企业的喜爱和支持。本文为大家着重介绍I…

Java开源工作流引擎有什么突出特点?

在高效办公需求日渐增长的当天&#xff0c;如何利用优质软件助力企业提升办公效率&#xff0c;是很多企业一直在寻觅的途径。Java开源工作流引擎可以借助其优势特点助力企业实现标准化发展&#xff0c;高效提高工作效率。那么&#xff0c;Java开源工作流引擎到底有什么用的突出…

后端web开发框架——Spring Boot

为什么使用Spring Boot 简化配置&#xff0c;无需编写太多的 xml 配置文件&#xff0c;效率很高&#xff1b;Spring 可以整合很多各式各样的框架&#xff0c;并能很好的集成&#xff1b;基于 Spring 构建&#xff0c;使开发者快速入门&#xff0c;门槛很低&#xff1b;Spring …