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

更多文章:


python语言程序设计是什么(python语言是什么)

python语言程序设计是什么(python语言是什么)

各位老铁们好,相信很多人对python语言程序设计是什么都不是特别的了解,因此呢,今天就来为大家分享下关于python语言程序设计是什么以及python语言是什么的问题知识,还望可以帮助大家,解决大家的一些困惑,下面一起来看看吧!

2026年10月15日 12:00

windows程序设计第五版(《WINDOWS程序设计》和《WINDOWS核心编程》的区别)

windows程序设计第五版(《WINDOWS程序设计》和《WINDOWS核心编程》的区别)

本篇文章给大家谈谈windows程序设计第五版,以及《WINDOWS程序设计》和《WINDOWS核心编程》的区别对应的知识点,文章可能有点长,但是希望大家可以阅读完,增长自己的知识,最重要的是希望对各位有所帮助,可以解决了您的问题,不要忘了

2026年10月15日 11:30

issued retroactively(FORM E上盖“ISSUED RETROACTIVELY”的问题,小女在线等待)

issued retroactively(FORM E上盖“ISSUED RETROACTIVELY”的问题,小女在线等待)

各位老铁们,大家好,今天由我来为大家分享issued retroactively,以及FORM E上盖“ISSUED RETROACTIVELY”的问题,小女在线等待的相关问题知识,希望对大家有所帮助。如果可以帮助到大家,还望关注收藏下本站

2026年10月15日 10:30

f发音是什么?printf的返回值是什么

f发音是什么?printf的返回值是什么

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

2026年10月15日 10:10

begin和start的区别(start与begin的区别)

begin和start的区别(start与begin的区别)

其实begin和start的区别的问题并不复杂,但是又很多的朋友都不太了解start与begin的区别,因此呢,今天小编就来为大家分享begin和start的区别的一些知识,希望可以帮助到大家,下面我们一起来看看这个问题的分析吧!

2026年10月15日 09:20

vant官网中文(范特365 是韩国化妆品VANT36.5吗)

vant官网中文(范特365 是韩国化妆品VANT36.5吗)

大家好,今天小编来为大家解答以下的问题,关于vant官网中文,范特365 是韩国化妆品VANT36.5吗这个很多人还不知道,现在让我们一起来看看吧!

2026年10月15日 09:10

特殊字符是指什么?正则表达式中一些特殊字符的用法

特殊字符是指什么?正则表达式中一些特殊字符的用法

大家好,特殊字符相信很多的网友都不是很明白,包括特殊字符是指什么也是一样,不过没有关系,接下来就来为大家分享关于特殊字符和特殊字符是指什么的一些知识点,大家可以关注收藏,免得下次来找不到哦,下面我们开始吧!

2026年10月15日 08:10

特殊符号网名大全花样符号(特殊符号昵称有哪些)

特殊符号网名大全花样符号(特殊符号昵称有哪些)

本篇文章给大家谈谈特殊符号网名大全花样符号,以及特殊符号昵称有哪些对应的知识点,文章可能有点长,但是希望大家可以阅读完,增长自己的知识,最重要的是希望对各位有所帮助,可以解决了您的问题,不要忘了收藏本站喔。

2026年10月15日 07:30

prison break(越狱(prison break)到底是在讲个什么)

prison break(越狱(prison break)到底是在讲个什么)

各位老铁们好,相信很多人对prison break都不是特别的了解,因此呢,今天就来为大家分享下关于prison break以及越狱(prison break)到底是在讲个什么的问题知识,还望可以帮助大家,解决大家的一些困惑,下面一起来看看

2026年10月15日 06:50

c程序设计第五版教学视频(求C程序设计(第五版)谭浩强教材源代码、视频课件等电子版资料!谢谢大家!)

c程序设计第五版教学视频(求C程序设计(第五版)谭浩强教材源代码、视频课件等电子版资料!谢谢大家!)

各位老铁们,大家好,今天由我来为大家分享c程序设计第五版教学视频,以及求C程序设计(第五版)谭浩强教材源代码、视频课件等电子版资料!谢谢大家!的相关问题知识,希望对大家有所帮助。如果可以帮助到大家,还望关注收藏下本站,您的支持是我们最大的动

2026年10月15日 06:40

最近更新

issued retroactively(FORM E上盖“ISSUED RETROACTIVELY”的问题,小女在线等待)
2026-10-15 10:30:03 浏览:0
热门文章

标签列表