写了一个Android代码,在eclipse已经编译通过了,但是在虚拟机却上不能运行,只是报下面的错误。

在eclipse上也没有说有错误,就是不能在虚拟机上运行。
下面是主代码:
public class SimpleTextActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
findView();
setListener();

}

double sum = 0;
private EditText ed1;
private EditText ed2;
private TextView tv1;
private Button b1;

public void findView() {

ed1 = (EditText) findViewById(R.id.edit1);
ed2 = (EditText) findViewById(R.id.edit2);
tv1 = (TextView) findViewById(R.id.text3);
b1 = (Button) findViewById(R.id.button);
}

public void setListener() {
b1.setOnClickListener((android.view.View.OnClickListener) calcB);
}

OnClickListener calcB = new OnClickListener() {

public void onClick(DialogInterface dialog, int which) {
double e1 = Double.parseDouble(ed1.getText().toString());
double e2 = Double.parseDouble(ed2.getText().toString());
sum = e1 * e2;
if (sum > 26) {
tv1.setText("@string/jianyi1");

} else if (sum < 20) {
tv1.setText("@string/jianyi3");

} else {
tv1.setText("@string/jianyi2");
}

}

};

}

SimpleTextActivity没有添加在AndroidManifest.xml文件中进行注册。你需要注册一下这个Activity,它才能正常运行。
<activity android:name="相对类名" />
温馨提示:内容为网友见解,仅供参考
第1个回答  2011-08-19
这种东西怎的好难哦,不过我是这谢谢。
第2个回答  2011-08-20
…………一般用到intent实现跳转才需要注册AndroidManifest,楼上怎么回事?
你的可能是监听或getSting处有问题,说一句,以后报错不要拿模拟器截图,这没用,要拿logcat截图才行的,把报错信息贴上来看看吧。
相似回答