

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)
文檔簡(jiǎn)介
1、上海電力學(xué)院嵌入式WebOS應(yīng)用開(kāi)發(fā)實(shí)驗(yàn)報(bào)告 實(shí)驗(yàn)名稱: 使用Android Developer SDK開(kāi)發(fā)應(yīng)用程序 專(zhuān) 業(yè): 姓 名: 班 級(jí): 學(xué) 號(hào): 一、 作品的運(yùn)行環(huán)境及安卓SDK基礎(chǔ)操作SDK Android Developer是一款在windows系統(tǒng)上運(yùn)行的針對(duì)Android應(yīng)用開(kāi)發(fā)的谷歌官方軟件(需要JAVA環(huán)境支持)。1、導(dǎo)入工程 2、建立虛擬機(jī) 在運(yùn)行虛擬機(jī)是為保證機(jī)器的順暢運(yùn)行建議選擇分辨率較低的虛擬機(jī),但是其RAM最好設(shè)為512MB,因?yàn)椴糠殖绦蛉绻{(diào)用資源過(guò)大會(huì)導(dǎo)致虛擬機(jī)無(wú)法運(yùn)行.3、虛擬機(jī)界面二、 作品介紹我的應(yīng)用是一個(gè)計(jì)算器。能實(shí)現(xiàn)包括小數(shù)的加減乘除運(yùn)算,結(jié)果過(guò)
2、大會(huì)自動(dòng)用科學(xué)記數(shù)法表示,另外還有退格跟清屏功能鍵。三、 編程以及運(yùn)行調(diào)試(一)、在MyDesktop主界面中添加應(yīng)用圖標(biāo)1。 首先在我的桌面上添加你應(yīng)用的圖標(biāo)以及文字,雙擊圖標(biāo)后就可以看見(jiàn)對(duì)應(yīng)的代碼,可直接在代碼中進(jìn)行修改圖片文字的大小顏色等等。以下是對(duì)應(yīng)圖像圖標(biāo)的代碼圖片可以在左側(cè)的選項(xiàng)中自行進(jìn)行挑選;也可以添加自己的圖片,只要將圖片放到對(duì)應(yīng)的文件夾之下在刷新就可以,但不建議放分辨率過(guò)高圖片可能會(huì)出現(xiàn)超出界面的等錯(cuò)誤。(二)、在res/layout目錄下新建。xml文件,由于計(jì)算器的按鈕很多,要在xml界面中添加排版: xml代碼首末的 /AbsoluteLayout> 格式較為自由
3、可以直接在界面中拖動(dòng)圖標(biāo)位置以及修改大小,而其他layout則更會(huì)自動(dòng)排列,各有優(yōu)劣。(三)、在src/weibo.test。ui目錄下新建。java文件,計(jì)算器的按鈕算法等都在此實(shí)現(xiàn)。(三)、聲明工程名1、在應(yīng)用中有三處需要聲明,首先是在AndroidManifest.xml2、然后是在MainActivity。java 四、 代碼展示(一)、。xml界面代碼<?xml version=”1.0" encoding="utf8”?<LinearLayout xmlns:android=”http://apk/res/and
4、roid" android:layout_width="fill_parent" android:layout_height="fill_parent" android:orientation=”vertical" <TableLayout android:id=”+id/tableLayout1” android:layout_width=”match_parent” android:layout_height="wrap_content" android:collapseColumns="4”
5、<TableRow android:id=”+id/tableRow_et” android:layout_width=”fill_parent" android:layout_height="fill_parent" EditText android:id="+id/et" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_span=”4” android:focusable=
6、”false” android:gravity=”right" android:inputType="text" android:singleLine="true" > /EditText /TableRow <TableRow android:id=”+id/tableRow1” android:layout_width=”fill_parent" android:layout_height=”fill_parent” > <Button android:id="+id/bt_7" and
7、roid:layout_width=”80px" android:layout_height="80px" android:text="7” /> Button android:id=”+id/bt_8” android:layout_width="80px” android:layout_height="80px" android:text="8" / Button android:id=”+id/bt_9” android:layout_width="1px” android:layo
8、ut_height="80px” android:text=”9" / <Button android:id="+id/bt_back" android:layout_width=”80px" android:layout_height="80px" android:text="back” / /TableRow> TableRow android:id=”+id/tableRow2" android:layout_width="fill_parent" android:l
9、ayout_height="fill_parent" > Button android:id="+id/bt_4" android:layout_width="80px" android:layout_height="80px" android:text=”4" / <Button android:id=”+id/bt_5" android:layout_width="80px" android:layout_height=”80px” android:text=
10、”5" /> Button android:id=”+id/bt_6” android:layout_width="80px" android:layout_height="80px” android:text="6" / Button android:id="+id/bt_divide" android:layout_width="80px" android:layout_height=”80px” android:text=”/” / </TableRow TableRow an
11、droid:id="+id/tableRow3” android:layout_width=”fill_parent" android:layout_height="fill_parent" <Button android:id="+id/bt_1" android:layout_width=”80px" android:layout_height=”80px" android:text=”1" / <Button android:id=”+id/bt_2" android:layo
12、ut_width=”80px" android:layout_height=”80px" android:text="2" /> Button android:id=”+id/bt_3” android:layout_width="80px" android:layout_height=”80px” android:text=”3" /> Button android:id="+id/bt_multiply” android:layout_width=”80px" android:layout
13、_height="80px" android:text=”*” / /TableRow TableRow android:id="+id/tableRow4" android:layout_width=”fill_parent" android:layout_height="fill_parent" > Button android:id=”+id/bt_0" android:layout_width="50px” android:layout_height="80px” android:
14、text=”0" /> Button android:id=”+id/bt_point" android:layout_width="50px" android:layout_height=”80px” android:text=”.” /> Button android:id="+id/bt_add” android:layout_width="50px" android:layout_height="80px” android:text=”+" / <Button android:i
15、d="+id/bt_sub” android:layout_width=”50px” android:layout_height=”80px" android:text=”" / </TableRow <TableRow android:id="+id/tableRow4" android:layout_width="fill_parent” android:layout_height="fill_parent" Button android:id=”+id/bt_equal" android
16、:layout_width=”fill_parent” android:layout_height="fill_parent” android:layout_span="3" android:text="=" / <Button android:id=”+id/bt_clear" android:layout_width=”50px" android:layout_height=”80px” android:text="clear" / /TableRow> /TableLayout/Line
17、arLayout(二)、.java功能代碼package weibo。test.ui;import java.util。ArrayList;import java.util.List;import android。app.Activity;import android。os。Bundle;import android.view。View;import android。view。View.OnClickListener;import android.widget.Button;import android。widget。EditText;import android.widget。Toast;i
18、mport weibo。lixiaodaoaaa.ui。R;import android.app。Activity;import android.content.Intent;import android。content。pm.PackageManager;import android.os.Bundle;import android。view。KeyEvent;import android.view。View;import android.view.View.OnClickListener;import android。widget。Button;import android。widget。
19、ListView;import com.zsy.flipper.AppInfUtil;import com.zsy。flipper。AppInfo;public class fffActivity extends Activity private Button bt_1;private Button bt_2;private Button bt_3;private Button bt_4;private Button bt_5;private Button bt_6;private Button bt_7;private Button bt_8;private Button bt_9;priv
20、ate Button bt_0;private Button bt_add;private Button bt_sub; / 減private Button bt_multiply; / 乘private Button bt_divide; / 除private Button bt_back;private Button bt_equal; / 等于private Button bt_point; / 點(diǎn)private Button bt_clear; / 清除private EditText et_play; / 顯示private String str_oper = ”+”; / 運(yùn)算符p
21、rivate StringBuffer str_display = new StringBuffer();; / 顯示private String str_result; / 結(jié)果顯示private double num1;private double num2;private boolean flag = true; / 小數(shù)點(diǎn)個(gè)數(shù)開(kāi)關(guān)控制;private boolean b_sub, b_mul, b_div; / 運(yùn)算符開(kāi)關(guān)控制Overridepublic void onCreate(Bundle savedInstanceState)super.onCreate(savedInstan
22、ceState);setContentView(R.layout.activity_fff);bt_0 = (Button) findViewById(R。id.bt_0);bt_1 = (Button) findViewById(R.id.bt_1);bt_2 = (Button) findViewById(R.id.bt_2);bt_3 = (Button) findViewById(R。id.bt_3);bt_4 = (Button) findViewById(R.id。bt_4);bt_5 = (Button) findViewById(R.id.bt_5);bt_6 = (Butto
23、n) findViewById(R.id。bt_6);bt_7 = (Button) findViewById(R。id.bt_7);bt_8 = (Button) findViewById(R。id.bt_8);bt_9 = (Button) findViewById(R.id。bt_9);bt_add = (Button) findViewById(R。id。bt_add);bt_sub = (Button) findViewById(R。id.bt_sub);bt_multiply = (Button) findViewById(R。id.bt_multiply);bt_divide =
24、 (Button) findViewById(R.id.bt_divide);bt_back = (Button) findViewById(R.id.bt_back);bt_equal = (Button) findViewById(R.id。bt_equal);bt_point = (Button) findViewById(R。id.bt_point);bt_clear = (Button) findViewById(R。id.bt_clear);et_play = (EditText) findViewById(R。id.et);et_play。setText(”0");bt
25、_0。setOnClickListener(new OnClickListener()Overridepublic void onClick(View v)str_display.append(”0");et_play。setText(str_display.toString()););bt_1.setOnClickListener(new OnClickListener()Overridepublic void onClick(View v)str_display。append("1");et_play。setText(str_display。toString(
26、););bt_2.setOnClickListener(new OnClickListener()Overridepublic void onClick(View v)str_display。append("2”);et_play。setText(str_display.toString()););bt_3.setOnClickListener(new OnClickListener()Overridepublic void onClick(View v)str_display。append("3");et_play。setText(str_display。toS
27、tring(););bt_4.setOnClickListener(new OnClickListener()Overridepublic void onClick(View v)str_display。append(”4”);et_play.setText(str_display。toString()););bt_5。setOnClickListener(new OnClickListener()Overridepublic void onClick(View v)str_display。append(”5”);et_play.setText(str_display.toString());
28、);bt_6。setOnClickListener(new OnClickListener()Overridepublic void onClick(View v)str_display。append("6”);et_play.setText(str_display。toString()););bt_7。setOnClickListener(new OnClickListener()Overridepublic void onClick(View v)str_display。append(”7");et_play。setText(str_display。toString()
29、;);bt_8。setOnClickListener(new OnClickListener()Overridepublic void onClick(View v)str_display。append(”8");et_play。setText(str_display。toString(););bt_9。setOnClickListener(new OnClickListener()Overridepublic void onClick(View v)str_display。append("9");et_play。setText(str_display。toStr
30、ing()););bt_point。setOnClickListener(new OnClickListener()Overridepublic void onClick(View v)if (flag)str_display。append(”。");flag = false;);bt_back。setOnClickListener(new OnClickListener()Overridepublic void onClick(View v)if (str_display。length() != 0)str_display.deleteCharAt(str_display。leng
31、th() - 1);et_play。setText(str_display。toString(););bt_add。setOnClickListener(new OnClickListener()Overridepublic void onClick(View v)str_oper = "+";if (!(str_display.toString() = "")num1 += Double。parseDouble(str_display.toString());str_display = new StringBuffer(”");if (!(s
32、tr_result = null))num1 = Double。parseDouble(str_result);str_result = null;et_play。setText(String。valueOf(num1));flag = true;);bt_sub。setOnClickListener(new OnClickListener()Overridepublic void onClick(View v)str_oper = "-”;if (!b_sub !(str_display.toString() = "")num1 = Double。parseDo
33、uble(str_display。toString();et_play。setText(String.valueOf(num1);str_display = new StringBuffer(”");b_sub = true; elseif (!(str_display.toString() = ”))num1 = Double.parseDouble(str_display.toString();str_display = new StringBuffer(”);if (?。╯tr_result = null)num1 = Double。parseDouble(str_result
34、);str_result = null;et_play.setText(String.valueOf(num1));flag = true;);bt_multiply.setOnClickListener(new OnClickListener()Overridepublic void onClick(View v)str_oper = "*";if (!b_mul & !(str_display。toString() = "")num1 = Double。parseDouble(str_display.toString());et_play。s
35、etText(String。valueOf(num1));str_display = new StringBuffer("");b_mul = true; elseif (!(str_display.toString() = ”")num1 = Double.parseDouble(str_display。toString();str_display = new StringBuffer(”);if (?。╯tr_result = null)num1 = Double。parseDouble(str_result);str_result = null;et_pla
36、y。setText(String.valueOf(num1));flag = true;);bt_divide.setOnClickListener(new OnClickListener()Overridepublic void onClick(View v)str_oper = "/"if (!b_div && !(str_display.toString() = ”)num1 = Double.parseDouble(str_display.toString());et_play.setText(String.valueOf(num1);str_dis
37、play = new StringBuffer("");b_div = true; elseif (!(str_display。toString() = ""))if (Double.parseDouble(str_display。toString()) = 0)Toast。makeText(fffActivity.this,"除數(shù)不能為0!”, Toast。LENGTH_LONG)。show(); elsenum1 /= Double。parseDouble(str_display。toString());str_display = new StringBuffer(”");if (!(str_result = null))num1 = Double。parseDouble(str_result);str_result = null;et_play.setText(String。valueOf(num1));flag = true;);bt_clear.setOnClickListener(new OnClickLis
溫馨提示
- 1. 本站所有資源如無(wú)特殊說(shuō)明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請(qǐng)下載最新的WinRAR軟件解壓。
- 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請(qǐng)聯(lián)系上傳者。文件的所有權(quán)益歸上傳用戶所有。
- 3. 本站RAR壓縮包中若帶圖紙,網(wǎng)頁(yè)內(nèi)容里面會(huì)有圖紙預(yù)覽,若沒(méi)有圖紙預(yù)覽就沒(méi)有圖紙。
- 4. 未經(jīng)權(quán)益所有人同意不得將文件中的內(nèi)容挪作商業(yè)或盈利用途。
- 5. 人人文庫(kù)網(wǎng)僅提供信息存儲(chǔ)空間,僅對(duì)用戶上傳內(nèi)容的表現(xiàn)方式做保護(hù)處理,對(duì)用戶上傳分享的文檔內(nèi)容本身不做任何修改或編輯,并不能對(duì)任何下載內(nèi)容負(fù)責(zé)。
- 6. 下載文件中如有侵權(quán)或不適當(dāng)內(nèi)容,請(qǐng)與我們聯(lián)系,我們立即糾正。
- 7. 本站不保證下載資源的準(zhǔn)確性、安全性和完整性, 同時(shí)也不承擔(dān)用戶因使用這些下載資源對(duì)自己和他人造成任何形式的傷害或損失。
最新文檔
- 學(xué)生自責(zé)測(cè)試題及答案
- 學(xué)生緩解壓力試題及答案
- 衛(wèi)校急救考試題及答案
- 2024年標(biāo)準(zhǔn)化備考計(jì)劃試題及答案
- 2024廣告設(shè)計(jì)師證書(shū)考試心理學(xué)試題及答案
- 【深企投產(chǎn)業(yè)研究院】2025AI眼鏡產(chǎn)業(yè)鏈研究報(bào)告-2025.4
- 商業(yè)美術(shù)設(shè)計(jì)師考試設(shè)計(jì)評(píng)估與反饋環(huán)節(jié)試題及答案
- 十九知識(shí)測(cè)試題及答案
- 人文知識(shí)考核試題及答案
- 產(chǎn)品特性與廣告廣告設(shè)計(jì)的匹配試題及答案
- “智慧課堂”展示課教學(xué)設(shè)計(jì)
- 2019阿那亞金山嶺中心小鎮(zhèn)生活手冊(cè)
- 預(yù)應(yīng)力張拉記錄四張表
- 豐田通商簡(jiǎn)介r
- 六氟丙烯安全技術(shù)說(shuō)明書(shū)MSDS
- 首信紅星國(guó)際廣場(chǎng)A地塊建設(shè)項(xiàng)目監(jiān)理規(guī)劃
- 人體穴位與天體對(duì)應(yīng)解密
- 機(jī)械行業(yè)六個(gè)典型事故案例分享
- run@rate表格實(shí)例
- 常減壓蒸餾裝置操作工操作技能試題(終).
- 控機(jī)床故障診斷與維修幾例
評(píng)論
0/150
提交評(píng)論