Team members: Chen Shuyun, Yang Jiane, Chen Xi
Team selection: Primary arithmetic App
First Sprint stage time: 11.17~11.27
This release is not yet completed function two (choice question):
Choiceactivity.java:
Package Com.example.calculator;import Java.util.random;import Android.os.bundle;import Android.app.ActionBar; Import Android.app.activity;import android.content.intent;import android.view.menu;import Android.view.MenuItem; Import Android.widget.button;import Android.widget.radiobutton;import Android.widget.textview;public class Choiceactivity extends Activity {private TextView text1,text2,text3;private RadioButton Radiobutton1,radiobutton2, Radiobutton3,radiobutton4;private Button btn;private Final random num1=new random ();p rivate final random num2=new random ();p rivate final Random r = new Random ();p rivate int x1;private int x2;private int x3;private char[] ch={' + ', '-', ' * ', '/'}; Character array private int index = R.nextint (ch.length); Random number, less than the length of the array, 0~3private char d=ch[index]; @Overrideprotected void OnCreate (Bundle savedinstancestate) {ActionBar Actionbar=getactionbar (); actionbar.setdisplayshowhomeenabled (true); actionbar.setdisplayhomeasupenabled (true); Super.oncreate (savedinstancestate); setconteNtview (R.layout.activity_choice); text1= (TextView) Findviewbyid (r.id.textview1); text2= (TextView) Findviewbyid ( R.ID.TEXTVIEW2); text3= (TextView) Findviewbyid (R.ID.TEXTVIEW3); radiobutton1= (RadioButton) Findviewbyid ( R.id.radiobutton1); radiobutton2= (RadioButton) Findviewbyid (R.id.radiobutton2); radiobutton3= (RadioButton) Findviewbyid (R.id.radiobutton3); radiobutton4= (RadioButton) Findviewbyid (r.id.radiobutton4); btn= (Button) Findviewbyid (R.id.button1); final string a=string.valueof (Num1.nextint); x1=integer.valueof (a); final string b= String.valueof (Num2.nextint); x2=integer.valueof (b); final String e=string.valueof (d); Text1.settext (a); Text3.settext (b); Text2.settext (e); Radiobutton1.settext (a); Radiobutton2.settext (b); @Overridepublic boolean Oncreateoptionsmenu (Menu menu) {//Inflate the menu; This adds items to the action bar if it is PR Esent.getmenuinflater (). Inflate (R.menu.choice, menu); return true;} @Overridepublic boolean onoptionsitemselected (MenuItem Item) {//TODO auto-generated method STUBSWItch (Item.getitemid ()) {case Android. r.id.home://Create intentintent intent=new Intent (This,typesactivity.class) to start mainactivity;//Add extra flag, Eject Intent.addflags (intent.flag_activity_clear_top) in activity stack above mainactivity, startactivity (Intent); Break;default:break;} return super.onoptionsitemselected (item);}}
Activity_choice.xml:
<relativelayout 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:paddi ngbottom= "@dimen/activity_vertical_margin" android:paddingleft= "@dimen/activity_horizontal_margin" Android: paddingright= "@dimen/activity_horizontal_margin" android:paddingtop= "@dimen/activity_vertical_margin" Android: background= "@drawable/animal" tools:context= ". Choiceactivity "> <textview android:id=" @+id/textview1 "android:layout_width=" 50DP "Android: layout_height= "Wrap_content" android:layout_margintop= "100DP"/> <textview android:id= "@+id/textVie W2 "Android:layout_width=" 30DP "android:layout_height=" wrap_content "android:layout_alignbaseline=" @+ Id/textview1 "android:layout_alignbottom=" @+id/textview1 "android:layout_torightof=" @+id/textView1 "/> <textviEW android:id= "@+id/textview3" android:layout_width= "50DP" android:layout_height= "Wrap_content" Android:layout_alignbaseline= "@+id/textview2" android:layout_alignbottom= "@+id/textview2" android:layout_t orightof= "@+id/textview2"/> <textview android:id= "@+id/textview4" android:layout_width= "Wrap_conte NT "android:layout_height=" Wrap_content "android:layout_alignbaseline=" @+id/textview3 "android:layout _alignbottom= "@+id/textview3" android:layout_torightof= "@+id/textview3" android:text= "="/> <RadioB Utton android:id= "@+id/radiobutton2" android:layout_width= "wrap_content" android:layout_height= "Wrap_ Content "android:layout_alignleft=" @+id/radiobutton1 "android:layout_centervertical=" true "/> <Radi Obutton android:id= "@+id/radiobutton3" android:layout_width= "wrap_content" android:layout_height= "Wra P_content "Android:layout_alignleft= "@+id/textview3" android:layout_below= "@+id/radiobutton2"/> <RadioButton androi D:id= "@+id/radiobutton4" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" and roid:layout_alignleft= "@+id/radiobutton3" android:layout_below= "@+id/radiobutton3"/> <Button Andro Id:id= "@+id/button1" android:layout_width= "wrap_content" android:layout_height= "Wrap_content" Android : layout_below= "@+id/radiobutton4" android:layout_centerhorizontal= "true" android:layout_margintop= "46DP" android:text= "OK"/> <radiobutton android:id= "@+id/radiobutton1" android:layout_width= "Wrap_con Tent "android:layout_height=" Wrap_content "android:layout_above=" @+id/radiobutton2 "android:layout_to leftof= "@+id/button1"/></relativelayout>
Operation Result:
Primary arithmetic app first sprint eighth day