然后当我按f8 a我得到:ZygoteInit $ methodandargscaller.run()来源未找到
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.copyup"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.copyup.MainActivity"
android:label="copy up" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Game"
android:label="Copy Up">
</activity>
<activity
android:name=".Rules"
android:label="Copy Up!">
</activity>
<activity
android:name=".Scores"
android:label="Copy Up!">
</activity>
<activity
android:name=".LearnCircle"
android:label="Copy Up!">
</activity>
<activity
android:name=".LearnHoriz"
android:label="Copy Up!">
</activity>
<activity
android:name=".LearnVert"
android:label="Copy Up!">
</activity>
<activity
android:name=".LearnMenu"
android:label="Copy Up!">
</activity>
</application>
</manifest>
和我的代码:
package com.example.copyup;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.View;
import android.widget.Button;
public class MainActivity extends Activity {
Button start, rules, hs, learn;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
linktoxml();
start.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(MainActivity.this, Game.class);
MainActivity.this.startActivity(myIntent);
}
});
/*
rules.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(MainActivity.this, Rules.class);
MainActivity.this.startActivity(myIntent);
}
});
hs.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(MainActivity.this, Scores.class);
MainActivity.this.startActivity(myIntent);
}
});
learn.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
Intent myIntent = new Intent(MainActivity.this, LearnMenu.class);
MainActivity.this.startActivity(myIntent);
}
});*/
//show shape, take reading after 4 seconds, compare with other, if true next, if false, end game
//dont make it complex with time reduce yet!!
}
private void linktoxml() {
start = (Button) findViewById(R.id.bcstart);
rules = (Button) findViewById(R.id.brules);
hs = (Button) findViewById(R.id.bhs);
learn = (Button) findViewById(R.id.blearn);
}
}
我尝试过清理项目,重新编写清单以及我能想到的一切。它可以工作,如果我注释掉代码中的按钮的链接,并将它们留在清单中但是当我解除它们的时候我得到这些错误,请帮助!!!
答案 0 :(得分:1)
问题是活动抛出异常。 eclipse在android SDK中查找源代码,但找不到它。
只需调试代码并找出代码抛出异常的位置。
答案 1 :(得分:0)
解决了它,现在感觉非常愚蠢,需要在定义按钮时才开始。