刚开始着手入门android,照着编的Sudiku程序,却出现错误,求解~
manifest中注册about activity不成功,还是无法运行about
manifest。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">
    <uses-sdk android:minSdkVersion="8" />    <application 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" />
            </intent-filter>
          </activity>
        <activity android:name=".About"></activity>
 </application>
</manifest>和没有注册前一样出现The application Sudoku has stopped unexpectedly,please try again.发愁了好久,照着例子写的却出错了~~~~~~坐等解答

解决方案 »

  1.   

    这个看着没有什么问题啊?你是不是“Sudoku”类继承错了啊??
      

  2.   

    错误提示并不是未注册Activity,是别的原因
      

  3.   

    这个是About.java
    package org.example.sudoku;
    import android.app.Activity;
    import android.os.Bundle;public class About extends Activity {
        /** Called when the activity is first created. */
        @Override
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
    setContentView(R.layout.about);
    }}
    下面的是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="@+d/about_content"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="@string/about_text"/>
    </Scrollview>
    最后是main.xml文件
    <?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:background="@color/background"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="30dip"           
        android:orientation="horizontal">
        <LinearLayout 
           android:orientation="vertical"
           android:layout_height="wrap_content"
           android:layout_width="fill_parent"
           android:layout_gravity="center">
            <TextView  
                android:layout_width="wrap_content" 
                android:layout_height="wrap_content" 
                android:text="@string/main_title" 
                android:layout_gravity="center"
                android:layout_marginBottom="25dip"
                android:textSize="24.5sp"/>
             <Button  
                android:id="@+id/continue_button"
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content" 
                android:text="@string/continue_label"/>
            <Button  
                android:id="@+id/new_game_button"
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content" 
                android:text="@string/new_game_label"/>
            <Button
                android:id="@+id/about_button"  
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content" 
                android:text="@string/about_label"/>
            <Button  
                android:id="@+id/exit_button"
                android:layout_width="fill_parent" 
                android:layout_height="wrap_content" 
                android:text="@string/exit_label"/>    </LinearLayout>
    </LinearLayout>
    在编译的时候没有提示出错啊??就是运行不出来~~
      

  4.   

    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);
            
            //Set up clicl listenners for all the buttons
            View continueButton=findViewById(R.id.continue_button);
            continueButton.setOnClickListener(this);
            View new_gameButton=findViewById(R.id.new_game_button);
            new_gameButton.setOnClickListener(this);
            View aboutButton=findViewById(R.id.about_button);
            aboutButton.setOnClickListener(this);
            View exitButton=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;
         //More buttons go here (if any)....
         }
        }
    }
      

  5.   

    <?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="@+d/about_content"  android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:text="@string/about_text"/>
    </Scrollview>