レイアウトを設定
Sudoku/res/layout/about.xml
- <!--xml version="1.0" encoding="utf-8"?-->
- <scrollview
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="fill_parent"
- android:layout_height="fill_parent"
- android:padding="10dip"
- >
- <textview
- android:id="@+id/about_content"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="@string/about_text"
- />
- </textview
- </scrollview
More...
Sudoku/res/values/strings.xml
- <!--xml version="1.0" encoding="utf-8"?-->
- <resources>
- <string name="app_name">Sudoku</string>
- <string name="main_title">Android Sudoku</string>
- <string name="continue_label">Continue</string>
- <string name="new_game_label">New Game</string>
- <string name="about_label">About</string>
- <string name="about_title">About Android Sudoku</string>
- <string name="about_text">\
- Sudoku is a logic-based number placement puzzle.
- Starting with a partially completed 9x9 grid, the
- objective is to fill the grid so that each row,
- each column, and each of the 3x3 boxes
- (also called <i>blocks</i>) contains the digits
- 1 to 9 exactly once.
- </string>
- <string name="exit_label">Exit</string>
- </resources>
Sudoku/src/org/example/sudoku/About.java
- package org.example.sudoku;
- import android.app.Activity;
- import android.os.Bundle;
- public class About extends Activity{
- @Override
- protected void onCreate(Bundle saveInstanceState) {
- super.onCreate(saveInstanceState);
- setContentView(R.layout.about);
- }
- }
Sudoku/src/org/example/sudoku/Sudoku.java
- package org.example.sudoku;
- import android.app.Activity;
- import android.os.Bundle;
- import android.content.Intent;
- import android.view.View;
- import android.view.View.OnClickListener;
- public class Sudoku extends Activity implements OnClickListener{
- /** Called when the activity is first created. */
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.main);
- View continueButton = this.findViewById(R.id.continue_button);
- continueButton.setOnClickListener(this);
- View newButton = this.findViewById(R.id.new_button);
- newButton.setOnClickListener(this);
- View aboutButton = this.findViewById(R.id.about_button);
- aboutButton.setOnClickListener(this);
- View exitButton = this.findViewById(R.id.exit_button);
- exitButton.setOnClickListener(this);
- }
- public void onClick(View v) {
- switch(v.getId()){
- case R.id.about_button:
- Intent i = new Intent(this, About.class);
- startActivity(i);
- break;
- }
- }
- }
Sudoku/AndroidManifest.xml
- <!--xml version="1.0" encoding="utf-8"?-->
- <manifest
- xmlns:android="http://schemas.android.com/apk/res/android"
- package="org.example.sudoku"
- android:versionCode="1"
- android:versionName="1.0">
- <application <brbr=""> android:icon="@drawable/icon"
- android:label="@string/app_name">
- <activity
- android:name=".Sudoku"
- android:label="@string/app_name">
- <intent-filter>
- <action android:name="android.intent.action.MAIN">
- <category android:name="android.intent.category.LAUNCHER">
- </category></action></intent-filter>
- <activity
- android:name=".About"
- android:label="@string/about_title">
- </activity
- </activity
- </application>
- <uses-sdk android:minsdkversion="3">
- </uses-sdk></manifest
About ボタンをクリックするとこんな感じ

0 件のコメント:
コメントを投稿