Course Name |
Mobile Internet development based on Android platform |
Date of experiment |
April 15, 2016 |
Name of the experimental project |
Design a simple landing interface |
Location of the experiment |
S3010 |
Type of experiment |
-Verification Type √ design type-comprehensive type |
Hours |
4 |
The purpose and requirements of the experiment (the knowledge points which are involved in this experiment and are required to be mastered) |
1 Objective: To realize the complete interface design of Sudoku game 2 Requirements: Master the use of Actionbar |
second, the experimental environment (the hardware equipment and related software used in this experiment) |
(1) PC Machine (2) Operating system: Windows XP (3) Software: Eclipse, jdk1.6,android Sdk,adt |
Third, the contents and steps of the experiment |
1) Import Project Sodoku 2) Add the following activity class 3) Add the following layout resource file 4) After the design is completed, the interface runs as follows |
Four, the experimental results (the experimental source program list and operating results or experimental conclusions, experimental design drawings) |
Code: Package Com.example.sudoku;import Com.example.sudoku.r.drawable;import com.example.sudoku.r.layout;import Android. R.color;import Android.os.bundle;import Android.annotation.suppresslint;import Android.app.ActionBar;import Android.app.activity;import Android.content.intent;import Android.content.res.resources;import Android.graphics.drawable.drawable;import Android.util.log;import Android.view.layoutinflater;import Android.view.menu;import Android.view.menuinflater;import Android.view.menuitem;import Android.view.View;import Android.view.view.onclicklistener;import Android.widget.button;import Android.widget.linearlayout;import Android.widget.relativelayout;import Android.widget.TextView; @SuppressLint ("Newapi") Public classMainactivity extends Activity {PrivateButton aboutbutbut,applybut; PrivateButton exitbut; PrivateTextView TV1; PrivateLinearLayout V; ActionBar ActionBar; @Overrideprotected voidonCreate (Bundle savedinstancestate) {super.oncreate (savedinstancestate); Setcontentview (R.layout.activity_main); Aboutbutbut=(Button) Findviewbyid (r.id.about); Applybut=(Button) Findviewbyid (r.id.apply); Exitbut=(Button) Findviewbyid (r.id.exit); V=(LinearLayout) Findviewbyid (R.ID.LINEARLAYOUT1); Bundle Bundle=NewBundle (); Bundle=getintent (). Getextras (); TV1=(TextView) Findviewbyid (R.ID.USERNAMETV); Tv1.settext ("your name is:"+bundle.getstring ("username")); ActionBar=Getactionbar (); Actionbar.show (); Aboutbutbut.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View arg0) {//TODO auto-generated Method StubIntent Intent =NewIntent (); Intent.setclass (mainactivity. This, About_main.class); StartActivity (Intent); Mainactivity. This. Finish (); } }); Exitbut.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View arg0) {//TODO auto-generated Method StubIntent intent=NewIntent (); Intent.setclass (mainactivity. This, Login_main.class); StartActivity (Intent); Mainactivity. This. Finish (); } }); Applybut.setonclicklistener (NewOnclicklistener () {@Override Public voidOnClick (View arg0) {//TODO auto-generated Method StubIntent intent=NewIntent (); Intent.setclass (mainactivity. This, Apply_main.class); StartActivity (Intent); } }); } @Override Publicboolean Oncreateoptionsmenu (Menu menu) {//inflate the menu; This adds items to the action bar if it is present.Menuinflater Inflater =NewMenuinflater ( This); Inflater.inflate (R.menu.main, menu); returnsuper.oncreateoptionsmenu (menu); } Publicboolean onoptionsitemselected (MenuItem item) {//TODO auto-generated Method StubResources Resources; Drawable btndrawable; Item.setchecked (true); Switch(Item.getitemid ()) { Caser.id.ai1_1:item.setchecked (true); Resources=Getbasecontext (). Getresources (); Btndrawable=resources.getdrawable (R.DRAWABLE.PPP); V.setbackground (btndrawable); Break; Caser.id.ai1_2:item.setchecked (true); Resources=Getbasecontext (). Getresources (); Btndrawable=resources.getdrawable (R.DRAWABLE.P2); V.setbackground (btndrawable); Break; Caser.id.ai1_3:item.setchecked (true); Resources=Getbasecontext (). Getresources (); Btndrawable=resources.getdrawable (R.DRAWABLE.P4); V.setbackground (btndrawable); Break; Caser.id.ai1_4:item.setchecked (true); Resources=Getbasecontext (). Getresources (); Btndrawable=resources.getdrawable (R.DRAWABLE.P3); V.setbackground (btndrawable); Break; Caser.id.ai1_5:item.setchecked (true); Resources=Getbasecontext (). Getresources (); Btndrawable=resources.getdrawable (R.DRAWABLE.P5); V.setbackground (btndrawable); Break; Caser.id.ai2:item.setchecked (true); Intent Intent=NewIntent (); Intent.setclass (mainactivity. This, Music_main.class); StartActivity (Intent); Break; Caser.id.ai3:item.setchecked (true); Intent Intent1=NewIntent (); Intent1.setclass (mainactivity. This, Help_main.class); StartActivity (INTENT1); Break; Caser.id.ai4:item.setchecked (true); Intent Intent2=NewIntent (); Intent2.setclass (mainactivity. This, About_main.class); StartActivity (Intent2); Caser.id.aix:item.setchecked (true); Intent Intentx=NewIntent (); Intentx.setclass (mainactivity. This, Newgame_main.class); StartActivity (INTENTX); default: Break; } returnsuper.onoptionsitemselected (item); }}
Run Result: () |
Five, Experimental summary (analysis of the results of the experiment, experience and improvement of experimental ideas) |
After this experiment, I think I still have a lot of deficiencies, in the experimental process is not very good independent completion, need to refer to some information and the comments of students to combine some of the previous documents, but I also learned the basic structure of Android application, how to write a simple Android application has a certain understanding. |
Experimental reviews |
|
Experimental results |
|
Guide Teacher Signature: Date |
|
|
|
|
|
|