Experiment 5 Sudoku Game Interface Design

Source: Internet
Author: User

Lab Report

Course Name

Mobile Internet development based on Android platform

Date of experiment

2016.4.8

Name of the experimental project

Sudoku Game Interface Design

Location of the experiment

S30002

Type of experiment

-Verification Type √ design type-comprehensive type

Hours

2

The purpose and requirements of the experiment (the knowledge points which are involved in this experiment and are required to be mastered)

Objective: To realize the complete interface design of Sudoku game

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:

Actionbar_memu.xml:

<?xml version= "1.0" encoding= "Utf-8"?>

<menu xmlns:android= "Http://schemas.android.com/apk/res/android" >

<item android:id= "@+id/newgameitem"

Android:title= "New Game"

Android:showasaction= "Always" >

</item>

<item android:id= "@+id/helpitem"

Android:title= "Help"

Android:showasaction= "Always" >

</item>

<item android:id= "@+id/aboutitem"

Android:title= "About"

Android:showasaction= "Always" >

</item>

<item android:id= "@+id/clockitem"

android:title= "Clock"

android:actionlayout= "@layout/clock"

Android:showasaction= "Always" >

</item>

</menu>

Mainactivity.java:

Package com.example.sukodu;

Import Android.annotation.SuppressLint;

Import Android.app.ActionBar;

Import android.app.Activity;

Import android.content.Intent;

Import Android.os.Bundle;

Import Android.util.Log;

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.TextView;

public class Mainactivity extends Activity {

Private Button exitbtn,aboutbtn;

Private TextView Tv1,titleview;

@SuppressLint ("Newapi")

@Override

protected void OnCreate (Bundle savedinstancestate) {

Super.oncreate (savedinstancestate);

Setcontentview (R.layout.activity_main);

tv1= (TextView) Findviewbyid (R.ID.TEXTVIEW1);

titleview= (TextView) Findviewbyid (r.id.maintitle);

LOG.I ("Test", "333333");

ActionBar ActionBar = Getactionbar ();//Get ActionBar Object

Actionbar.setdisplayshowhomeenabled (TRUE);//Display application icon

Actionbar.setdisplayhomeasupenabled (TRUE);//Convert the application icon to a clickable icon and add a return arrow.

Final Intent intent=getintent (); Get Intent Object

Bundle Bundle=intent.getextras (); Get the packets passed

Tv1.settext ("Your name is:" +bundle.getstring ("UserName"));

Aboutbtn= (Button) Findviewbyid (R.ID.ABOUT_BTN);

Exitbtn= (Button) Findviewbyid (R.ID.EXIT_BTN);

Exitbtn.setonclicklistener (New Onclicklistener () {

@Override

public void OnClick (View v) {

TODO auto-generated Method Stub

StartActivity (Intent);

Setresult (0x1717,intent);

LOG.I ("Test", "444444");

Finish ();

}

});

Aboutbtn.setonclicklistener (New Onclicklistener () {

@Override

public void OnClick (View arg0) {

TODO auto-generated Method Stub

Intent intent=new Intent ();

Intent.setclass (Mainactivity.this, Secondactivity.class);

StartActivity (Intent);

Finish ();

}

});

}

@Override

public boolean Oncreateoptionsmenu (Menu menu) {

Inflate the menu; This adds items to the action bar if it is present.

Menuinflater inflater = new Menuinflater (this);

Inflater.inflate (R.menu.actionbar_menu, menu);

return Super.oncreateoptionsmenu (menu);

}

@Override

public boolean onoptionsitemselected (MenuItem item) {

TODO auto-generated Method Stub

Intent Intent;

Switch (Item.getitemid ()) {

Case Android. R.id.home:

Create a intent to start mainactivity

Intent=new Intent (This,loginactivity.class);

Add additional flag to eject activity on the activity stack that is above mainactivity

Intent.addflags (Intent.flag_activity_clear_top);

StartActivity (Intent);

Break

Case R.id.newgameitem:

Create a intent to start mainactivity

Intent=new Intent (This,new_game.class);

Add additional flag to eject activity on the activity stack that is above mainactivity

Intent.addflags (Intent.flag_activity_clear_top);

StartActivity (Intent);

Break

Case R.id.helpitem:

Create a intent to start mainactivity

Intent=new Intent (This,help.class);

Add additional flag to eject activity on the activity stack that is above mainactivity

Intent.addflags (Intent.flag_activity_clear_top);

StartActivity (Intent);

Break

Case R.id.aboutitem:

Create a intent to start mainactivity

Intent=new Intent (This,about.class);

Add additional flag to eject activity on the activity stack that is above mainactivity

Intent.addflags (Intent.flag_activity_clear_top);

StartActivity (Intent);

Break

Default

Break

}

return super.onoptionsitemselected (item);

}

}

Run Result: ()

Five, Experimental summary (analysis of the results of the experiment, experience and improvement of experimental ideas)

The experiment learned how to use the Actionbar, understand in what occasions use it, harvest a lot, very much like the experiment class on Android.

Experimental reviews

Experimental results

Guide Teacher Signature: Date

Experiment 5 Sudoku Game Interface Design

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.