Android应用程序的活动清单文件错误

Android应用程序的活动清单文件错误,android,Android,我正在尝试添加一个活动。我正在尝试创建一个应用程序 <activity android:name=".About" android:label="@string/about_title" android:theme="@android:style/Theme.Dialog"> </activity> My sudoku.java文件代码: public class Sudoku extends Activi

我正在尝试添加一个活动。我正在尝试创建一个应用程序

<activity android:name=".About"
          android:label="@string/about_title"
          android:theme="@android:style/Theme.Dialog">            
</activity>
My sudoku.java文件代码:

public class Sudoku extends Activity implements OnClickListener{

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.main);

    View continueButton = findViewById(R.id.continue_button);
    continueButton.setOnClickListener((OnClickListener) this);
    View newButton = findViewById(R.id.new_button);
    newButton.setOnClickListener((OnClickListener) this);
    View aboutButton = findViewById(R.id.about_button);
    aboutButton.setOnClickListener((OnClickListener) this);
    View exitButton = findViewById(R.id.exit_button);
    exitButton.setOnClickListener((OnClickListener) this);
}

public void onClick(View v) {
    switch (v.getId()) {
    case R.id.about_button:
    Intent i = new Intent(this, About.class);
    startActivity(i);
    break;

    }
}
这是main.xml文件

android:background=“@color/background”
android:padding=“30dip”
android:orientation=“水平”
android:layout\u width=“fill\u parent”
android:layout\u height=“fill\u parent”>

检查第20行的代码,它是NullPointerException

08-02 07:25:51.153: E/AndroidRuntime(270): Caused by: java.lang.NullPointerException

08-02 07:25:51.153: E/AndroidRuntime(270): at org.example.sudoku.Sudoku.onCreate(Sudoku.java:20)

我想你必须输入你的观点

View continueButton = (View)findViewById(R.id.continue_button);
    continueButton.setOnClickListener((OnClickListener) this);
    View newButton = (View)findViewById(R.id.new_button);
    newButton.setOnClickListener((OnClickListener) this);
    View aboutButton = (View)findViewById(R.id.about_button);
    aboutButton.setOnClickListener((OnClickListener) this);
    View exitButton = (View)findViewById(R.id.exit_button);
    exitButton.setOnClickListener((OnClickListener) this);
试试dis,我希望它对你有用

或者你必须做这样的改变

Button continueButton = (Button)findViewById(R.id.continue_button);
        continueButton.setOnClickListener((OnClickListener) this);
        View newButton = (Button)findViewById(R.id.new_button);
        newButton.setOnClickListener((OnClickListener) this);
        View aboutButton = (Button)findViewById(R.id.about_button);
        aboutButton.setOnClickListener((OnClickListener) this);
        View exitButton = (Button)findViewById(R.id.exit_button);
        exitButton.setOnClickListener((OnClickListener) this);

在代码中将“新建”按钮更改为“新建游戏”按钮
因为在XML中,它被写为“新建游戏”按钮,但在代码中,您使用它作为“新建按钮”

除此之外,您是否在您的应用程序中收到添加消息?在你的Sudoku.java文件中,第20行抛出了一个NullPointerException,发布该文件,这样我们就可以找出它。日志cat 08-02 07:25:51.093:D/AndroidRuntime(270)中显示的错误:关闭VM 08-02 07:25:51.093:W/dalvikvm(270):threadid=1:线程退出,但未捕获异常(组=0x4001d800)08-02 07:25:51.153:E/AndroidRuntime(270):致命异常:main 08-02 07:25:51.153:E/AndroidRuntime(270):java.lang.RuntimeException:无法启动活动组件信息{org.example.sudoku/org.example.sudoku.sudoku}:java.lang.NullPointerException 08-02 07:25:51.153:E/AndroidRuntime(270):在android.app.ActivityThread.PerformlLaunchActivity(ActivityThread.java:2663)发布你的
Sudoku
类。在
onCreate
中有一些错误。发布你的main.xml源代码。我是android新手。因此,如果你能简要介绍一下,这将非常有帮助。我应该在哪里查找。在这里,我给出我的Sudoku类。受保护的void onCreate(Bundle savedInstanceState){super.onCreate(savedInstanceState);setContentView(R.layout.main);View continueButton=findViewById(R.id.continue_按钮);continueButton.setOnClickListener((OnClickListener)this);View newButton=findViewById(R.id.new_按钮);newButton.setOnClickListener((OnClickListener)this);关于按钮的视图;aboutButton.setOnClickListener((OnClickListener)this);View exitButton=findViewById(R.id.exit_按钮);exitButton.setOnClickListener((OnClickListener)this);}嘿,Yushulx我添加了数独类。我在这里找不到任何问题。你能帮我一下吗。这是新的游戏按钮而不是新的按钮。这就是为什么你得到空值
View continueButton = (View)findViewById(R.id.continue_button);
    continueButton.setOnClickListener((OnClickListener) this);
    View newButton = (View)findViewById(R.id.new_button);
    newButton.setOnClickListener((OnClickListener) this);
    View aboutButton = (View)findViewById(R.id.about_button);
    aboutButton.setOnClickListener((OnClickListener) this);
    View exitButton = (View)findViewById(R.id.exit_button);
    exitButton.setOnClickListener((OnClickListener) this);
Button continueButton = (Button)findViewById(R.id.continue_button);
        continueButton.setOnClickListener((OnClickListener) this);
        View newButton = (Button)findViewById(R.id.new_button);
        newButton.setOnClickListener((OnClickListener) this);
        View aboutButton = (Button)findViewById(R.id.about_button);
        aboutButton.setOnClickListener((OnClickListener) this);
        View exitButton = (Button)findViewById(R.id.exit_button);
        exitButton.setOnClickListener((OnClickListener) this);