日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区

您的位置:首頁技術(shù)文章
文章詳情頁

android studio實(shí)現(xiàn)簡(jiǎn)單考試應(yīng)用程序?qū)嵗a詳解

瀏覽:22日期:2022-09-25 09:20:52

一、問題

1、如圖所示,設(shè)計(jì)一個(gè)包含四種題型的簡(jiǎn)單考試應(yīng)用程序(具體考試題目可以選用以下設(shè)計(jì),也可以自己另外確定),項(xiàng)目名稱:zuoye06_666 ;(666,改成自己的實(shí)際編號(hào))。

2、布局管理器任選(約束布局相對(duì)容易實(shí)現(xiàn))。

3、“提交”按鈕的Text通過字符串資源賦值,不要直接輸入“提交”兩個(gè)字。

4、每題按25分計(jì)算,編寫相應(yīng)的程序,答題完成后單擊“提交”按鈕,在“總得分:”右邊文本框中顯示實(shí)際得分;同時(shí),顯示一個(gè)Toast消息框:

答對(duì)不足3題,顯示:“還需努力啊!”;

答對(duì)3題,顯示:“祝賀你通過考試!”;

全部答對(duì),顯示:“你真棒!祝賀你!”

android studio實(shí)現(xiàn)簡(jiǎn)單考試應(yīng)用程序?qū)嵗a詳解

二、分析

1.這次作業(yè)比較簡(jiǎn)單,就是上課講的東西的集合,練習(xí)spinner、checkbox、radiobutton、edittext以及button的監(jiān)聽,還有setText和Toast用法。

2.注意點(diǎn),要考慮到正常考試的時(shí)候?qū)W生第一次選對(duì)后來改錯(cuò),或者一開始選錯(cuò)后來改對(duì)的情況,考生的分?jǐn)?shù)應(yīng)該由最后一次監(jiān)聽到結(jié)果來確定,所以添加了boolean類型的以及checkbox的計(jì)數(shù)。

三、代碼

1.布局代碼

<?xml version='1.0' encoding='utf-8'?><androidx.constraintlayout.widget.ConstraintLayout xmlns:android='http://schemas.android.com/apk/res/android' xmlns:app='http://schemas.android.com/apk/res-auto' xmlns:tools='http://schemas.android.com/tools' android:layout_width='match_parent' android:layout_height='match_parent' tools:context='.MainActivity'> <TextView android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:text='Android基礎(chǔ)知識(shí)測(cè)評(píng)' app:layout_constraintBottom_toBottomOf='parent' app:layout_constraintHorizontal_bias='0.498' app:layout_constraintLeft_toLeftOf='parent' app:layout_constraintRight_toRightOf='parent' app:layout_constraintTop_toTopOf='parent' app:layout_constraintVertical_bias='0.058' /> <EditText android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:layout_marginStart='16dp' android:ems='3' android:inputType='textPersonName' app:layout_constraintBottom_toBottomOf='@+id/textView' app:layout_constraintStart_toStartOf='parent' app:layout_constraintTop_toTopOf='@+id/textView' app:layout_constraintVertical_bias='0.615' /> <TextView android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:layout_marginTop='20dp' android:text='@string/di1ti' app:layout_constraintStart_toEndOf='@+id/et_on' app:layout_constraintTop_toBottomOf='@+id/textView2' /> <TextView android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:layout_marginTop='20dp' android:text='@string/di2ti' app:layout_constraintStart_toStartOf='@+id/et_on' app:layout_constraintTop_toBottomOf='@+id/textView' /> <RadioGroup android: android:layout_width='113dp' android:layout_height='64dp' app:layout_constraintStart_toStartOf='@+id/textView3' app:layout_constraintTop_toBottomOf='@+id/textView3'> <RadioButton android: android:layout_width='match_parent' android:layout_height='wrap_content' android:text='開源的' /> <RadioButton android: android:layout_width='match_parent' android:layout_height='wrap_content' android:text='非開源的' /> </RadioGroup> <TextView android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:layout_marginTop='20dp' android:text='@string/di3ti' app:layout_constraintStart_toStartOf='@+id/textView3' app:layout_constraintTop_toBottomOf='@+id/radioGroup' /> <CheckBox android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:layout_marginStart='60dp' android:text='JAVA' app:layout_constraintStart_toEndOf='@+id/cb1' app:layout_constraintTop_toBottomOf='@+id/textView4' /> <CheckBox android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:text='JDK' app:layout_constraintStart_toStartOf='@+id/textView4' app:layout_constraintTop_toBottomOf='@+id/textView4' /> <CheckBox android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:layout_marginStart='60dp' android:text='SDK' app:layout_constraintStart_toEndOf='@+id/cb2' app:layout_constraintTop_toBottomOf='@+id/textView4' /> <TextView android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:layout_marginTop='20dp' android:text='@string/di4ti' app:layout_constraintStart_toStartOf='@+id/textView4' app:layout_constraintTop_toBottomOf='@+id/cb1' /> <Spinner android: android:layout_width='130dp' android:layout_height='30dp' android:entries='@array/Systems' app:layout_constraintStart_toStartOf='@+id/textView5' app:layout_constraintTop_toBottomOf='@+id/textView5' /> <TextView android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:layout_marginStart='104dp' android:layout_marginBottom='36dp' android:text='總得分:' app:layout_constraintBottom_toTopOf='@+id/button' app:layout_constraintStart_toStartOf='parent' /> <TextView android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:background='#F1ED06' android:text=' 00 ' app:layout_constraintBottom_toBottomOf='@+id/textView6' app:layout_constraintEnd_toEndOf='parent' app:layout_constraintHorizontal_bias='0.025' app:layout_constraintStart_toEndOf='@+id/textView6' app:layout_constraintTop_toTopOf='@+id/textView6' app:layout_constraintVertical_bias='0.0' /> <Button android: android:layout_width='wrap_content' android:layout_height='wrap_content' android:layout_marginBottom='20dp' android:text='@string/subscribe' app:layout_constraintBottom_toBottomOf='parent' app:layout_constraintEnd_toEndOf='parent' app:layout_constraintStart_toStartOf='parent' /> </androidx.constraintlayout.widget.ConstraintLayout>

2.strings.xml

<resources> <string name='app_name'>zuoye06_231</string> <string name='di1ti'>年11月5日,Google發(fā)布安卓系統(tǒng)(答:2007)</string> <string name='di2ti'>Android操作系統(tǒng)是(答:開源的)</string> <string name='di3ti'>Android Studio 開發(fā)Android程序,還需安裝:(1、3)</string> <string name='di4ti'>Android是基于?平臺(tái)手機(jī)的操作系統(tǒng)(Linux)</string> <string name='subscribe'>提交</string></resources>

3.Systems.xml

<?xml version='1.0' encoding='utf-8'?><resources> <string-array name='Systems'> <item>Windows</item> <item>Linux</item> <item>Mac</item> </string-array></resources>

4.java代碼

package com.example.lenovo.zuoye06_231; import androidx.appcompat.app.AppCompatActivity; import android.os.Bundle;import android.view.KeyEvent;import android.view.View;import android.widget.AdapterView;import android.widget.Button;import android.widget.CheckBox;import android.widget.RadioButton;import android.widget.RadioGroup;import android.widget.Spinner;import android.widget.TextView;import android.widget.Toast;import android.widget.CompoundButton; public class MainActivity extends AppCompatActivity { static int i = 0,cb_num = 0; boolean rd_num = false,sp_num = false,et_num = false; TextView sorce; TextView et_on; RadioGroup rd; Button button; CheckBox checkBox1; CheckBox checkBox2; CheckBox checkBox3; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); //定義 et_on = findViewById(R.id.et_on); sorce = findViewById(R.id.sorce); rd = findViewById(R.id.radioGroup); button = findViewById(R.id.button); checkBox1 = findViewById(R.id.cb1); checkBox2 = findViewById(R.id.cb2); checkBox3 = findViewById(R.id.cb3); //為每個(gè)復(fù)選按鈕設(shè)置狀態(tài)改變監(jiān)聽器 checkBox1.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){ @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // TODO Auto-generated method stub if(isChecked) cb_num++; else cb_num--; } }); checkBox2.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){ @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // TODO Auto-generated method stub if(isChecked) cb_num--; else cb_num++; } }); checkBox3.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener(){ @Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { // TODO Auto-generated method stub if(isChecked) cb_num++; else cb_num--; } }); //設(shè)置單選按鈕組添加事件監(jiān)聽 rd.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() { @Override public void onCheckedChanged(RadioGroup group, int checkedId) { //獲取被選擇的單選按鈕 RadioButton r = (RadioButton) findViewById(checkedId); if(r.getText().equals('開源的')) rd_num = true; else rd_num = false; } }); //edittext監(jiān)聽 et_on.setOnEditorActionListener(new TextView.OnEditorActionListener() { @Override public boolean onEditorAction(TextView textView, int i, KeyEvent keyEvent) { if(et_on.getText().toString().equals('2007')) et_num = true; else et_num = false; return false; } }); //獲取下拉列表對(duì)象 final Spinner spinner = (Spinner) findViewById(R.id.spinner); //為Spinner添加選擇監(jiān)聽器 spinner.setOnItemSelectedListener(new AdapterView.OnItemSelectedListener() { @Override //數(shù)據(jù)選擇事件處理 public void onItemSelected(AdapterView<?> parent, View view, int pos, long id) { String[] Systems = getResources().getStringArray(R.array.Systems); //顯示選擇結(jié)果 if(Systems[pos].equals('Linux')) sp_num = true; else sp_num = false; } //以下方法重寫必須有 @Override public void onNothingSelected(AdapterView<?> parent) { // Another interface callback } }); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(cb_num == 2) i++; if(sp_num) i++; if(et_num) i++; if(rd_num) i++; sorce.setText(' '+(i*25)+' '); if(i == 4) Toast.makeText(MainActivity.this,'你真棒!祝賀你!', Toast.LENGTH_SHORT).show(); else if(i == 3) Toast.makeText(MainActivity.this,'祝賀你通過考試!', Toast.LENGTH_SHORT).show(); else Toast.makeText(MainActivity.this,'還需努力啊!', Toast.LENGTH_SHORT).show(); } }); }}

四、結(jié)論

1.當(dāng)用戶填寫的時(shí)候最終答案是按最后修改的來確定的。

2.考慮到正常情況下當(dāng)用戶提交后數(shù)據(jù)已經(jīng)上傳到網(wǎng)絡(luò)上,所以沒有添加不能二次修改的代碼,因此測(cè)試的時(shí)候會(huì)出現(xiàn)第一次提交后不退出,修改后結(jié)果會(huì)出問題。

五、參考文章

3.29更新如果想要解決不能2次修改問題可以加一個(gè)狀態(tài)標(biāo)志符。

如果想要解決二次提交后累加的問題,可以在Toast后加一個(gè)i=0。

到此這篇關(guān)于android studio實(shí)現(xiàn)簡(jiǎn)單考試應(yīng)用程序的文章就介紹到這了,更多相關(guān)android studio實(shí)現(xiàn) 考試應(yīng)用程序內(nèi)容請(qǐng)搜索好吧啦網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持好吧啦網(wǎng)!

標(biāo)簽: Android
相關(guān)文章:
日本不卡不码高清免费观看,久久国产精品久久w女人spa,黄色aa久久,三上悠亚国产精品一区二区三区
久久精品国产精品亚洲毛片| 国产精品毛片| 日本h片久久| 日本伊人午夜精品| 日韩欧美中文字幕电影| 日本不卡高清| 欧美一区二区三区免费看| 欧美天堂一区| 岛国精品一区| 亚洲高清二区| 欧美一区三区| 国产亚洲福利| 免播放器亚洲一区| 欧美日韩1区2区3区| 欧美黑人做爰爽爽爽| 中文字幕在线看片| 亚洲美洲欧洲综合国产一区| 蜜桃久久av一区| 欧美日本不卡| 日韩精品91| 欧美综合二区| 国产精品亚洲人成在99www| 麻豆精品一区二区综合av| 国产精品白浆| 亚洲一级少妇| 在线亚洲观看| 青草国产精品| 欧美激情另类| 亚洲尤物在线| 国产精品传媒麻豆hd| 日韩免费在线| 另类亚洲自拍| 国产精品激情电影| 欧美精品日日操| 蜜桃视频免费观看一区| 老牛国内精品亚洲成av人片| 成人亚洲欧美| 蜜臀精品一区二区三区在线观看 | 亚洲精品综合| 欧美aaaaaa午夜精品| 久久精品成人| 青青草伊人久久| 亚洲天堂资源| 亚洲精品黄色| 日韩不卡一区| 蜜臀va亚洲va欧美va天堂 | 日韩久久精品| 亚洲精品伦理| 日本不良网站在线观看| 亚洲色图国产| 三级在线看中文字幕完整版| 性欧美精品高清| 精品高清久久| 亚洲人成毛片在线播放女女| 国产suv精品一区| 丝袜美腿亚洲一区二区图片| 精品女同一区二区三区在线观看| 国产视频一区免费看| 国产精品hd| 久久亚洲电影| 三级小说欧洲区亚洲区| 天堂av在线一区| 成人日韩av| 亚洲精品九九| 欧美日一区二区| 久久99久久人婷婷精品综合| 成人av二区| 久久不见久久见中文字幕免费| 黑丝美女一区二区| 久久影院资源站| 日本久久二区| 日韩视频一区| 福利精品在线| 日本91福利区| 国精品一区二区三区| 国产精品xxx在线观看| 一二三区精品| 亚洲精品中文字幕乱码| 高清不卡一区| 国产精品大片| 日本va欧美va瓶| 婷婷综合网站| 美女一区网站| 加勒比视频一区| 国产日韩欧美中文在线| 免费不卡在线观看| 91精品高清| 午夜精品久久久久久久久久蜜桃| 麻豆中文一区二区| 欧美亚洲二区| 日本aⅴ免费视频一区二区三区| 鲁大师成人一区二区三区| 国产一区日韩一区| 久久九九精品| 肉色欧美久久久久久久免费看| 麻豆精品在线视频| 日韩不卡一二三区| 久久亚洲美女| 日韩专区欧美专区| 夜夜精品视频| 在线亚洲自拍| 午夜在线播放视频欧美| 美女久久久久| 亚洲一级少妇| 欧产日产国产精品视频| 精品国产精品国产偷麻豆 | 麻豆精品av| 国产欧美日韩在线观看视频| 亚洲毛片在线免费| 亚洲精品乱码| 日韩精品a在线观看91| 亚洲色图网站| 亚洲3区在线| 日本91福利区| 久久精品97| 国产麻豆一区| 麻豆国产欧美日韩综合精品二区| 国产精品最新| 欧美激情福利| 里番精品3d一二三区| 美女毛片一区二区三区四区最新中文字幕亚洲 | 国产欧美日韩视频在线| 日日摸夜夜添夜夜添国产精品| 丝袜美腿一区二区三区| 首页国产欧美久久| 中文字幕免费精品| 日韩av中文字幕一区| 久久99精品久久久野外观看| 国产麻豆精品| 精品日韩一区| 久久三级视频| 亚洲一区欧美二区| 久久国产精品久久w女人spa| 最近国产精品视频| 国产探花在线精品| 黄色欧美在线| 欧美日韩中文一区二区| 亚洲欧美高清| 亚洲久久在线| 国产乱人伦丫前精品视频| 久久99国产精品视频| 欧美一区久久久| 欧美在线亚洲综合一区| 中文字幕中文字幕精品| 国产精品一级| 国产 日韩 欧美一区| 国产视频亚洲| 日韩欧美中文字幕一区二区三区| 国产欧美一区二区三区米奇| 久久精品国产久精国产爱| 日韩精品一区二区三区免费观看| 亚洲黄色在线| 青青青国产精品| 精品高清久久| 国产国产精品| 日韩不卡一二三区| 色一区二区三区四区| 欧美va天堂在线| 国产精品毛片在线看| 日韩av午夜在线观看| 老司机免费视频一区二区三区| 老牛影视精品| 亚洲精品在线观看91| 亚洲精品系列| 高清日韩欧美| 免费一级片91| 久久久91麻豆精品国产一区| 日韩精品一卡| 日韩精品亚洲一区二区三区免费| 国产福利亚洲| 欧美日韩国产探花| 青草国产精品久久久久久| 国产一区二区三区视频在线| 婷婷综合激情| 国产激情综合| 婷婷综合社区| 久久99久久人婷婷精品综合| 伊人精品一区| 国产午夜精品一区在线观看| 国产91精品对白在线播放| 日韩精品亚洲专区| 成人羞羞视频播放网站| 日韩avvvv在线播放| 日韩欧美午夜| 日本亚州欧洲精品不卡| 青青青免费在线视频| 亚洲a级精品| 天堂中文在线播放| 日韩国产91| 欧美成人日韩| 久久不见久久见免费视频7| 亚洲大全视频| 久久av影院| 日韩中文字幕一区二区三区| 成人日韩av| 日韩激情一区二区| 欧美日韩黑人| 91亚洲一区| 国产欧美一区二区三区国产幕精品| 九九久久电影|