android开发实例源代码(Android开发,怎么看源代码)

:暂无数据 2026-10-01 10:50:02 :0

android开发实例源代码(Android开发,怎么看源代码)

大家好,如果您还对android开发实例源代码不太了解,没有关系,今天就由本站为大家分享android开发实例源代码的知识,包括Android开发,怎么看源代码的问题都会给大家分析到,还望可以解决大家的问题,下面我们就开始吧!

本文目录

Android开发,怎么看源代码

先看下AndroidManifest.xml 里面有些主要的信息如权限哇有哪些activity之类的。找到主要的activity之后看又哪些资源在res中看主要是看又哪些控件呀键值对之类的,看activity对应那个布局界面,然后懂了就看java的处理了。懂了API这些东西都不难。

开发一个简易的计算器APP程序 Android源代码

下面是效果展示:



复制代码代码如下:


《?xml version=“1.0“ encoding=“utf-8“?》
《LinearLayout xmlns:android=“s/android“
android:layout_width=“match_parent“
android:layout_height=“match_parent“
android:orientation=“vertical“ 》

《LinearLayout android:layout_width=“fill_parent“
android:layout_height=“wrap_content“》
《TextView
android:id=“@+id/tvResult“
android:layout_width=“fill_parent“
android:layout_height=“wrap_content“
android:height=“50dp“
android:text=“@string/tvResult“
/》
《/LinearLayout》
《LinearLayout android:layout_width=“fill_parent“
android:layout_height=“wrap_content“》
《Button
android:id=“@+id/btnBackspace“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:width=“150dp“
android:layout_marginLeft=“10dp“
android:text=“@string/btnbackspace“/》
《Button
android:id=“@+id/btnCE“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:width=“150dp“
android:text=“@string/btnCE“/》
《/LinearLayout》
《LinearLayout android:layout_width=“fill_parent“
android:layout_height=“wrap_content“》
《Button
android:id=“@+id/btn7“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:layout_marginLeft=“10dp“
android:width=“75dp“
android:text=“@string/btn7“/》
《Button
android:id=“@+id/btn8“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:width=“75dp“
android:text=“@string/btn8“/》
《Button
android:id=“@+id/btn9“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:width=“75dp“
android:text=“@string/btn9“/》
《Button
android:id=“@+id/btnDiv“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:width=“75dp“
android:text=“@string/btnDiv“/》
《/LinearLayout》
《LinearLayout android:layout_width=“fill_parent“
android:layout_height=“wrap_content“》
《Button
android:id=“@+id/btn4“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:layout_marginLeft=“10dp“
android:width=“75dp“
android:text=“@string/btn4“/》
《Button
android:id=“@+id/btn5“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:width=“75dp“
android:text=“@string/btn5“/》
《Button
android:id=“@+id/btn6“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:width=“75dp“
android:text=“@string/btn6“/》
《Button
android:id=“@+id/btnMul“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:width=“75dp“
android:text=“@string/btnMul“/》
《/LinearLayout》
《LinearLayout android:layout_width=“fill_parent“
android:layout_height=“wrap_content“》
《Button
android:id=“@+id/btn1“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:layout_marginLeft=“10dp“
android:width=“75dp“
android:text=“@string/btn1“/》
《Button
android:id=“@+id/btn2“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:width=“75dp“
android:text=“@string/btn2“/》
《Button
android:id=“@+id/btn3“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:width=“75dp“
android:text=“@string/btn3“/》
《Button
android:id=“@+id/btnAdd“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:width=“75dp“
android:text=“@string/btnAdd“/》
《/LinearLayout》
《LinearLayout android:layout_width=“fill_parent“
android:layout_height=“wrap_content“》
《Button
android:id=“@+id/btn0“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:layout_marginLeft=“10dp“
android:width=“75dp“
android:text=“@string/btn0“/》
《Button
android:id=“@+id/btnC“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:width=“75dp“
android:text=“@string/btnC“/》
《Button
android:id=“@+id/btnEqu“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:width=“75dp“
android:text=“@string/btnEqu“/》
《Button
android:id=“@+id/btnSub“
android:layout_width=“wrap_content“
android:layout_height=“wrap_content“
android:width=“75dp“
android:text=“@string/btnSub“/》
《/LinearLayout》
《/LinearLayout》

复制代码代码如下:


package com.example.week2;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;
import android.app.Activity;

public class MainActivity extends Activity  implements OnClickListener{

//声明一些控件
Button btn0=null;
Button btn1=null;
Button btn2=null;
Button btn3=null;
Button btn4=null;
Button btn5=null;
Button btn6=null;
Button btn7=null;
Button btn8=null;
Button btn9=null;
Button btnBackspace=null;
Button btnCE=null;
Button btnC=null;
Button btnAdd=null;
Button btnSub=null;
Button btnMul=null;
Button btnDiv=null;
Button btnEqu=null;
TextView tvResult=null;
//声明两个参数。接收tvResult前后的值
double num1=0,num2=0;
double Result=0;//计算结果
int op=0;//判断操作数,
boolean isClickEqu=false;//判断是否按了“=”按钮

@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
//从布局文件中获取控件,
btn0=(Button)findViewById(R.id.btn0);
btn1=(Button)findViewById(R.id.btn1);
btn2=(Button)findViewById(R.id.btn2);
btn3=(Button)findViewById(R.id.btn3);
btn4=(Button)findViewById(R.id.btn4);
btn5=(Button)findViewById(R.id.btn5);
btn6=(Button)findViewById(R.id.btn6);
btn7=(Button)findViewById(R.id.btn7);
btn8=(Button)findViewById(R.id.btn8);
btn9=(Button)findViewById(R.id.btn9);
btnBackspace=(Button)findViewById(R.id.btnBackspace);
btnCE=(Button)findViewById(R.id.btnCE);
btnC=(Button)findViewById(R.id.btnC);
btnEqu=(Button)findViewById(R.id.btnEqu);
btnAdd=(Button)findViewById(R.id.btnAdd);
btnSub=(Button)findViewById(R.id.btnSub);
btnMul=(Button)findViewById(R.id.btnMul);
btnDiv=(Button)findViewById(R.id.btnDiv);
tvResult=(TextView)findViewById(R.id.tvResult);

//添加监听\
btnBackspace.setOnClickListener(this);
btnCE.setOnClickListener(this);

btn0.setOnClickListener(this);
btn1.setOnClickListener(this);
btn2.setOnClickListener(this);
btn3.setOnClickListener(this);
btn4.setOnClickListener(this);
btn5.setOnClickListener(this);
btn6.setOnClickListener(this);
btn7.setOnClickListener(this);
btn8.setOnClickListener(this);
btn9.setOnClickListener(this);


btnAdd.setOnClickListener(this);
btnSub.setOnClickListener(this);
btnMul.setOnClickListener(this);
btnDiv.setOnClickListener(this);
btnEqu.setOnClickListener(this);
}
@Override
public void onClick(View v) {
switch (v.getId()) {
//btnBackspace和CE--------------------
case R.id.btnBackspace:
String myStr=tvResult.getText().toString();
try {
tvResult.setText(myStr.substring(0, myStr.length()-1));
} catch (Exception e) {
tvResult.setText(““);
}

break;
case R.id.btnCE:
tvResult.setText(null);
break;

//btn0--9---------------------------
case R.id.btn0:
if(isClickEqu)
{
tvResult.setText(null);
isClickEqu=false;
}
String myString=tvResult.getText().toString();
myString+=“0“;
tvResult.setText(myString);
break;
case R.id.btn1:
if(isClickEqu)
{
tvResult.setText(null);
isClickEqu=false;
}
String myString1=tvResult.getText().toString();
myString1+=“1“;
tvResult.setText(myString1);
break;
case R.id.btn2:
if(isClickEqu)
{
tvResult.setText(null);
isClickEqu=false;
}
String myString2=tvResult.getText().toString();
myString2+=“2“;
tvResult.setText(myString2);
break;
case R.id.btn3:
if(isClickEqu)
{
tvResult.setText(null);
isClickEqu=false;
}
String myString3=tvResult.getText().toString();
myString3+=“3“;
tvResult.setText(myString3);
break;
cas

Android开发,怎么看源代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于Android开发,怎么看源代码、Android开发,怎么看源代码的信息别忘了在本站进行查找哦。

android开发实例源代码(Android开发,怎么看源代码)

本文编辑:admin

更多文章:


协方差计算公式(协方差的计算公式)

协方差计算公式(协方差的计算公式)

这篇文章给大家聊聊关于协方差计算公式,以及协方差的计算公式对应的知识点,希望对各位有所帮助,不要忘了收藏本站哦。

2026年10月11日 08:10

易语言网页api接口怎么调用(易语言,怎么读取网页json的api)

易语言网页api接口怎么调用(易语言,怎么读取网页json的api)

本篇文章给大家谈谈易语言网页api接口怎么调用,以及易语言,怎么读取网页json的api对应的知识点,文章可能有点长,但是希望大家可以阅读完,增长自己的知识,最重要的是希望对各位有所帮助,可以解决了您的问题,不要忘了收藏本站喔。

2026年10月11日 08:00

majority of(the majority of 和 a majority of的区别以及用法例句)

majority of(the majority of 和 a majority of的区别以及用法例句)

这篇文章给大家聊聊关于majority of,以及the majority of 和 a majority of的区别以及用法例句对应的知识点,希望对各位有所帮助,不要忘了收藏本站哦。

2026年10月11日 07:40

汉字机内码查询表(1个汉字的机内码是几位谢谢)

汉字机内码查询表(1个汉字的机内码是几位谢谢)

大家好,关于汉字机内码查询表很多朋友都还不太明白,不过没关系,因为今天小编就来为大家分享关于1个汉字的机内码是几位谢谢的知识点,相信应该可以解决大家的一些困惑和问题,如果碰巧可以解决您的问题,还望关注下本站哦,希望对各位有所帮助!

2026年10月11日 07:20

promote翻译(英语翻译倡导怎么说)

promote翻译(英语翻译倡导怎么说)

其实promote翻译的问题并不复杂,但是又很多的朋友都不太了解英语翻译倡导怎么说,因此呢,今天小编就来为大家分享promote翻译的一些知识,希望可以帮助到大家,下面我们一起来看看这个问题的分析吧!

2026年10月11日 06:30

用手机如何导航?开车用手机导航哪个软件最好

用手机如何导航?开车用手机导航哪个软件最好

今天给各位分享用手机如何导航的知识,其中也会对用手机如何导航进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

2026年10月11日 06:20

多线程技术有什么用(多线程有什么作用)

多线程技术有什么用(多线程有什么作用)

其实多线程技术有什么用的问题并不复杂,但是又很多的朋友都不太了解多线程有什么作用,因此呢,今天小编就来为大家分享多线程技术有什么用的一些知识,希望可以帮助到大家,下面我们一起来看看这个问题的分析吧!

2026年10月11日 05:40

another time(another time和other time的区别)

another time(another time和other time的区别)

大家好,another time相信很多的网友都不是很明白,包括another time和other time的区别也是一样,不过没有关系,接下来就来为大家分享关于another time和another time和other time的区

2026年10月11日 05:00

java开发工具包jdk(JDK是什么意思)

java开发工具包jdk(JDK是什么意思)

其实java开发工具包jdk的问题并不复杂,但是又很多的朋友都不太了解JDK是什么意思,因此呢,今天小编就来为大家分享java开发工具包jdk的一些知识,希望可以帮助到大家,下面我们一起来看看这个问题的分析吧!

2026年10月11日 04:50

mysql 命令(MySQL的基本命令)

mysql 命令(MySQL的基本命令)

大家好,如果您还对mysql 命令不太了解,没有关系,今天就由本站为大家分享mysql 命令的知识,包括MySQL的基本命令的问题都会给大家分析到,还望可以解决大家的问题,下面我们就开始吧!

2026年10月11日 03:00

最近更新

majority of(the majority of 和 a majority of的区别以及用法例句)
2026-10-11 07:40:02 浏览:0
热门文章

标签列表