当前位置: 代码迷 >> Android >> android编译时没异常,但是不能执行,
  详细解决方案

android编译时没异常,但是不能执行,

热度:41   发布时间:2016-05-01 15:07:45.0
android编译时没错误,但是不能执行,求救!
我按教程做了一个乘法的计算器,没有错误,但是模拟器总是弹出
  Waiting for debugger
Application Act(process roy.act)is waiting for the debugger to attach.

这是什么问题!!!!搞不懂啊,代码是
//ActActivity.java
package roy.act;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

public class ActActivity extends Activity {
  /** Called when the activity is first created. */
private Button myButton = null;
private TextView myTextView =null;
private EditText e1=null;
private EditText e2=null;
  @Override
  public void onCreate(Bundle savedInstanceState) {
  super.onCreate(savedInstanceState);
  setContentView(R.layout.main);
  e1=(EditText)findViewById(R.id.e1);
  e2=(EditText)findViewById(R.id.e2);
  myTextView =(TextView)findViewById(R.id.myTextview);
  myButton =(Button)findViewById(R.id.myButton);
  myTextView.setText("乘以");
  myButton.setText("计算");
  myButton.setOnClickListener(new MyButtonListener());
  }
  public boolean onCreateOptionsMenu(Menu menu)
  {
  menu.add(0,1,1,"退出");
  menu.add(0,2,2,"关于");
  return super.onCreateOptionsMenu(menu);
  }
  public boolean onOptionsItemSelected(MenuItem item)
  {
  if(item.getItemId()==1)
  {
  finish();
  }
  return super.onOptionsItemSelected(item);
  }
  class MyButtonListener implements OnClickListener
  {
  public void onClick(View v)
  {
 
  String ed1=e1.getText().toString();
  String ed2=e2.getText().toString();
  Intent intent=new Intent();
  intent.putExtra("one", ed1);
  intent.putExtra("two", ed2);
  intent.setClass(ActActivity.this,activity02.class);
  ActActivity.this.startActivity(intent);
  }
  }
}

//activity02
package roy.act;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TextView;

public class activity02 extends Activity{
  private TextView myTextView02=null;
  @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.other);
myTextView02=(TextView)findViewById(R.id.myTextView02);
Intent intent =getIntent();
String ed3=intent.getStringExtra("one");
String ed4=intent.getStringExtra("two");
int i3=Integer.parseInt(ed3);
int i4=Integer.parseInt(ed4);
int result=i3*i4;
myTextView02.setText(result+"");
}

}


//main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="fill_parent"
  android:layout_height="fill_parent"
  android:orientation="vertical" >
  <EditText
  android:id="@+id/e1"
  android:layout_width="fill_parent"
  android:layout_height="wrap_content"
  />
  相关解决方案