意图错误 - 进程意外停止

时间:2011-08-30 16:24:28

标签: android android-intent

我的申请需要一些帮助。我有这些课程:

Ajuda.class

public class Ajuda extends Activity {
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.ajuda);
    }
}

testes.class

public class teste extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        MenuInflater inflater = getMenuInflater();
        inflater.inflate(R.menu.menu, menu);
        return true;
    }

    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.mnuAjuda:
            Intent i = new Intent (this.getApplicationContext(),
                                   Ajuda.class);
            this.startActivity(i);
            return true;
        default: return super.onOptionsItemSelected(item);
        }
    }
}

onOptionsItemSelected中的方法case R.id.mnuAjuda上:如果我有

Intent i = new Intent (this.getApplicationContext(),  
    Ajuda.class);  
    this.startActivity(i);

而不是

setContentView(R.layout.ajuda);

申请意外停止,我不知道为什么。

1 个答案:

答案 0 :(得分:1)

你有没有像

这样的东西
<activity android:name=".Ajuda" android:label="Ajuda" />

AndroidManifest.xml