Android开发:跳转界面时出现错误

黄涛11 发布于 2012/04/07 12:52
阅读 2K+
收藏 0

你好,我是刚学Android开发的,做程序多数是参考书本,所以可能有些隐藏的内容没留意,或者说是不懂,我昨天搞了个Android跳转窗体的程序,但是老是那个错误:The application 填写用户信息(process User.Text)has stopped unexpectedly.Please try again.上网查好像是意外错误,这就麻烦了,什么叫意外错误···我不懂耶,所以只能求救了,下面是第一个窗体的代码

 

package User.Text;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.EditText;
import android.widget.RadioButton;
import android.widget.Spinner;

public class UserActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
       
        //设置下拉框数据源
  ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.carrer_array, android.R.layout.simple_spinner_item);
  adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
  Spinner spinner = (Spinner)findViewById(R.id.spinner1);
  spinner.setAdapter(adapter);
  
  //监听点击按钮
  Button button = (Button)findViewById(R.id.button1);
  button.setOnClickListener(new View.OnClickListener() {
     public void onClick(View v) {
      
          //跳转页面
    Intent intent = new Intent(UserActivity.this,Chatter.class);
    
    //实例化并获取各种控件的值
    EditText editText1 = (EditText)findViewById(R.id.EditText01);
    CharSequence text1 = editText1.getText();
    
    RadioButton mRadioButton01 = (RadioButton)findViewById(R.id.radioButton1);
    RadioButton mRadioButton02 = (RadioButton)findViewById(R.id.radioButton2);
    CharSequence text2 = "";
    if (mRadioButton01.isChecked()) {
     text2 = mRadioButton01.getText(); 
    }
    if (mRadioButton02.isChecked()) {
     text2 = mRadioButton02.getText(); 
    }
    
    EditText editText2 = (EditText)findViewById(R.id.editText1);
    CharSequence text3 = editText2.getText();

    Spinner spinner = (Spinner)findViewById(R.id.spinner1);
    CharSequence text4 = spinner.getSelectedItem().toString();

    //将传送的数据放置在共同存储区,变量:TEXT1,TEXT2,TEXT3,TEXT4
    intent.putExtra("TEXT1", text1 );
    intent.putExtra("TEXT2", text2 );
    intent.putExtra("TEXT3", text3 );
    intent.putExtra("TEXT4", text4 );
    
    //切换到Chatter,同时等待回应,设定requestCode=SHOW_EDITOR
    startActivity(intent);
   }
  });
    }
   
}

加载中
0
苦行瓜
苦行瓜
你这个错误信息没什么价值的,具体还要看ddms输出的那团红字。估计楼主没有在manifest.xml里注册该activity吧。
黄涛11
哦,原来还有注册这步骤,问题解决了,谢谢
返回顶部
顶部