Android写了一个简单的计算器程序,Unfortunately,Activity01 has stopped
packagenet.Activity01.space;importandroid.app.Activity;importandroid.content.Intent;i...
package net.Activity01.space;
import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.EditText;import android.widget.TextView;
public class Activity01Activity extends Activity { private EditText factorOne; private EditText factorTwo; private TextView symbol; private Button calculate; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); factorOne = (EditText)findViewById(R.id.factorOne); factorTwo = (EditText)findViewById(R.id.factorTwo); symbol = (TextView)findViewById(R.id.symbol); calculate = (Button)findViewById(R.id.calculate); symbol.setText(R.string.symbol); calculate.setText(R.string.calculate); calculate.setOnClickListener(new myOnClickListener()); } class myOnClickListener implements OnClickListener {
@Override public void onClick(View arg0) { // TODO Auto-generated method stub String factorOnestr = factorOne.getText().toString(); String factorTwostr = factorTwo.getText().toString(); Intent intent = new Intent(); intent.putExtra("one" ,factorOnestr); intent.putExtra("two" ,factorTwostr); intent.setClass(Activity01Activity.this, Activity02.class); Activity01Activity.this.startActivity(intent); } }} 展开
import android.app.Activity;import android.content.Intent;import android.os.Bundle;import android.view.View;import android.view.View.OnClickListener;import android.widget.Button;import android.widget.EditText;import android.widget.TextView;
public class Activity01Activity extends Activity { private EditText factorOne; private EditText factorTwo; private TextView symbol; private Button calculate; /** Called when the activity is first created. */ @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); factorOne = (EditText)findViewById(R.id.factorOne); factorTwo = (EditText)findViewById(R.id.factorTwo); symbol = (TextView)findViewById(R.id.symbol); calculate = (Button)findViewById(R.id.calculate); symbol.setText(R.string.symbol); calculate.setText(R.string.calculate); calculate.setOnClickListener(new myOnClickListener()); } class myOnClickListener implements OnClickListener {
@Override public void onClick(View arg0) { // TODO Auto-generated method stub String factorOnestr = factorOne.getText().toString(); String factorTwostr = factorTwo.getText().toString(); Intent intent = new Intent(); intent.putExtra("one" ,factorOnestr); intent.putExtra("two" ,factorTwostr); intent.setClass(Activity01Activity.this, Activity02.class); Activity01Activity.this.startActivity(intent); } }} 展开
2014-01-21
展开全部
看看logcat里面报的什么错。
追问
Binary XML file line #7: Error inflating class EditView
追答
没有editview,只有TextView和EditText
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询