求一个用appinventor计算器写的简单计算器apk,急!!!

App Inventor编程开发集锦2-计算器-第2课-实现常规操作 - 少儿编程教育网安卓Android 编写一个简单的计算器_百度文库
您的浏览器Javascript被禁用,需开启后体验完整功能,
享专业文档下载特权
&赠共享文档下载特权
&10W篇文档免费专享
&每天抽奖多种福利
两大类热门资源免费畅读
续费一年阅读会员,立省24元!
安卓Android 编写一个简单的计算器
&&需要完整的源代码 私信我或者发我邮箱明情况(注:下载才发!)
阅读已结束,下载本文需要
定制HR最喜欢的简历
下载文档到电脑,同时保存到云知识,更方便管理
加入VIP
还剩8页未读,
定制HR最喜欢的简历
你可能喜欢app inventor 计算器怎么做?急求。_百度知道
app inventor 计算器怎么做?急求。
答题抽奖
首次认真答题后
即可获得3次抽奖机会,100%中奖。
到百度阅读里搜一下&App Inventor开发集锦&,有一章专门讲解计算器的开发.
采纳率:63%
来自团队:
为您推荐:
其他类似问题
inventor的相关知识
换一换
回答问题,赢新手礼包
个人、企业类
违法有害信息,请在下方选择后提交
色情、暴力
我们会通过消息、邮箱等方式尽快将举报结果通知您。写一个简单的Android计算器应用
最近学习Android,所以写了一个计算器练手。里面涉及到了基本的组件和布局,还有sqlite数据库,Intent方法。有兴趣的新手朋友可以直接贴代码来做做,增加写学习的兴趣。项目结构如图:AuthorActivity.javapackage com.example.android_test6_6_12;
import android.app.A
import android.content.I
import android.os.B
import android.view.V
public class AuthorActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.author);
public void toFirst(View v){
Intent in = new Intent(AuthorActivity.this,MainActivity.class);
startActivity(in);
MainActivity.javapackage com.example.android_test6_6_12;
import java.util.C
import java.util.D
import android.R.
import android.app.A
import android.content.I
import android.database.C
import android.database.sqlite.SQLiteD
import android.os.B
import android.view.M
import android.view.MenuI
import android.view.V
import android.widget.EditT
import android.widget.TextV
import android.widget.T
public class MainActivity extends Activity {
private TextView tv,tv2;
private String str= "0",first="",second = "",result = "0";
private SQLiteD
private EditT
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
tv2 = (TextView) findViewById(R.id.et_input);
tv = (TextView) findViewById(R.id.result);
db = SQLiteDatabase.openOrCreateDatabase(this.getFilesDir()+"/data2.db", null);
Calendar data = Calendar.getInstance();
String a =
data.getTime()+"";
db.execSQL("create table saveData(id integer primary key autoincrement,data text);");
}catch(Exception e){
Toast.makeText(this, a, 1).show();
public void nine(View v){
if(str=="0"){
str = "9";
tv.setText(first);
str = str + "9";
tv2.setText(str);
public void eight(View v){
if(str=="0"){
str = "8";
tv.setText(first);
str = str + "8";
tv2.setText(str);
public void seven(View v){
if(str=="0"){
str = "7";
tv.setText(first);
str = str + "7";
tv2.setText(str);
public void six(View v){
if(str=="0"){
str = "6";
tv.setText(first);
str = str + "6";
tv2.setText(str);
public void five(View v){
if(str=="0"){
str = "5";
tv.setText(first);
str = str + "5";
tv2.setText(str);
public void four(View v){
if(str=="0"){
str = "4";
tv.setText(first);
str = str + "4";
tv2.setText(str);
public void three(View v){
if(str=="0"){
str = "3";
tv.setText(first);
str = str + "3";
tv2.setText(str);
public void two(View v){
if(str=="0"){
str = "2";
tv.setText(first);
str = str + "2";
tv2.setText(str);
public void one(View v){
if(str=="0"){
str = "1";
tv.setText(first);
str = str + "1";
tv2.setText(str);
public void zero(View v){
if(str=="0"){
str = "0";
tv.setText(first);
str = str + "0";
tv2.setText(str);
public void dot(View v){
if(str=="0"){
str = "0.";
tv.setText(first);
str = str + ".";
tv2.setText(str);
public void plus(View v){
if(str==""){
str = "0"+"+";
str = str +"+";
tv2.setText(str);
public void minus(View v){
if(str==""){
str = "0"+"-";
str = str +"-";
tv2.setText(str);
public void times(View v){
if(str==""){
str = "0"+"*";
str = str +"*";
tv2.setText(str);
public void divide(View v){
if(str==""){
str = "0"+"/";
str = str +"/";
tv2.setText(str);
public void eq(View v){
result = tv2.getText().toString();
String[] a = result.split("\\+|\\-|\\*|\\/");
String[] b = result.split("\\d+\\.?\\d?");
if(result.contains("*")||result.contains("/")){
for(int i=0;i&b.i++){
if(b[i].contains("*")){
double sum = (double)Integer.parseInt(a[i])*(double)Integer.parseInt(a[i-1]);
a[i-1] = 0+"";
a[i] = sum+"";
b[i] = b[i-1];
}else if(b[i].contains("/")){
double sum = (double)Integer.parseInt(a[i-1])/(double)Integer.parseInt(a[i]);
a[i-1] = 0+"";
a[i] = sum+"";
b[i] = b[i-1];
if(result.contains("+")||result.contains("-")){
for(int i=0;i&b.i++){
if(b[i].contains("+")){
double sum = (double)Integer.parseInt(a[i])+(double)Integer.parseInt(a[i-1]);
a[i-1] = 0+"";
a[i] = sum+"";
b[i] = b[i-1];
}else if(b[i].contains("-")){
double sum = (double)Integer.parseInt(a[i-1])-(double)Integer.parseInt(a[i]);
a[i-1] = 0+"";
a[i] = sum+"";
b[i] = b[i-1];
tv.setText(str);
first = "="+a[a.length-1];
tv2.setText(first);
second = str+
public void clear(View v){
tv2.setText("0");
public void backspace(View v){
String[] str2 = str.split("");
str2[str2.length-1]="";
for(String s:str2){
str = str +s;
tv2.setText(str);
public void saveDB(View v){
if(str!=""){
db.execSQL("insert into saveData values(null,'"+str+"');");
db.execSQL("insert into saveData values(null,'"+second+"');");
Toast.makeText(this, "保存成功!", 1).show();
public void p_m(View v){
setContentView(R.layout.savedb_info);
et = (EditText) findViewById(R.id.et_save);
Cursor c = db.rawQuery("select * from saveData ", null);
String text = "编号\t\t\t\t\t\t\t\t数值\n";
while(c.moveToNext()){
text = text +c.getInt(0)+"\t\t\t\t\t\t\t\t\t\t"+c.getString(1)+"\n";
et.setText(text);
public void back(View v){
setContentView(R.layout.activity_main);
tv2 = (TextView) findViewById(R.id.et_input);
tv = (TextView) findViewById(R.id.result);
public void author(View v){
Intent in = new Intent(MainActivity.this,AuthorActivity.class);
startActivity(in);
activity_main.xml&LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.android_test6_6_12.MainActivity"
android:background="@drawable/girl"
android:orientation="vertical"&
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="36sp"
android:id="@+id/result"
android:gravity="right"
android:hint="暂不支持多数运算和小数点" /&
android:textSize="25sp"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="@+id/et_input"
android:numeric="integer"
android:gravity="right"/&
&TableLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:stretchColumns="0,1,2,3,4"&
&TableRow &
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="C"
android:onClick="clear"/&
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="B"
android:onClick="backspace"/&
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="query"
android:onClick="p_m"/&
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="save"
android:onClick="saveDB"/&
&/TableRow&
&TableRow &
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="7"
android:onClick="seven"/&
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="8"
android:onClick="eight"/&
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="9"
android:onClick="nine"/&
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="+"
android:onClick="plus"/&
&/TableRow&
&TableRow &
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="4"
android:onClick="four"/&
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="5"
android:onClick="five"/&
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="6"
android:onClick="six"/&
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="-"
android:onClick="minus"/&
&/TableRow&
&TableRow &
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="1"
android:onClick="one"/&
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="2"
android:onClick="two"/&
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3"
android:onClick="three"/&
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="*"
android:onClick="times"/&
&/TableRow&
&TableRow &
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="。"
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="0"
android:onClick="zero"/&
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="="
android:onClick="eq"/&
android:textSize="25sp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="/"
android:onClick="divide"/&
&/TableRow&
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="作者信息"
android:onClick="author"/&
&/TableLayout&
&/LinearLayout&
author.xml&?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/boys"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="返回"
android:onClick="toFirst"
android:layout_gravity="right|bottom"/&
&/LinearLayout&
savedb_info.xml&?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:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="返回"
android:textSize="25sp"
android:onClick="back"/&
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text=""
android:textSize="25sp"
android:id="@+id/et_save"/&
&/LinearLayout&
AndroidManifest.xml&?xml version="1.0" encoding="utf-8"?&
&manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.android_test6_6_12"
android:versionCode="1"
android:versionName="1.0" &
android:minSdkVersion="21"
android:targetSdkVersion="21" /&
&application
android:allowBackup="true"
android:icon="@drawable/app_icon"
android:label="@string/app_name"
android:theme="@style/AppTheme" &
android:name=".MainActivity"
android:label="@string/app_name" &
&intent-filter&
&action android:name="android.intent.action.MAIN" /&
&category android:name="android.intent.category.LAUNCHER" /&
&/intent-filter&
&/activity&
android:name=".AuthorActivity"
android:label="@string/app_name" &
&/activity&
&/application&
&/manifest&
因为计算的逻辑代码有些考虑不全,所以有些小bug。运行结果如图:记得往drawable中放图片。
第一个Android项目--简易计算器的设计与实现
android开发实例学习笔记之简易计算器的开发
android简单计算器实现
Android实现简单的计算器
Android简单计算器实现
Android实现简单计算器功能(Button控件实现)
Android 精准的加减乘除运算
没有更多推荐了,为Android智能手机编写应用程序MIT App Inventor(AppInventor)v2.3.0 官方版下载__飞翔下载
单机游戏下载单机游戏下载基地
当前位置: →
→ 为Android智能手机编写应用程序MIT App Inventor(AppInventor) v2.3.0 官方版
这是谷歌推出一种软件工具。这种工具可以使用户更容易的为Android智能手机编写应用程序。说明:开发一个App Inventor程序就从您的浏览器开始,您首先要设计程序的外观。接着是设定程序的行为,这部分就像玩乐高一样简单有趣。最后只要将手机与电脑联接,刚出炉的程序就会出现在您的手机上了。而且这款编程软件不一定非要是专业的研发人员,甚至根本不需要掌握任何的程序编制知识。因为这款软件已经事先将软件的代码全部编写完毕,用户只需要根据自己的需求向其中添加服务选项即可。也就是我们所要做的只是写简单的代码拼装程序。App Inventor于日移交给麻省理工学院行动学习中心(MIT),并公布使用。
安卓官方手机版
IOS官方手机版
为Android智能手机编写应用程序MIT App Inventor(AppInventor) v2.3.0 官方版
本类软件分类
装机必备软件

我要回帖

更多关于 appinventor撞球 的文章

 

随机推荐