package com.yanjun;


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;

public class MainActivity extends Activity {
/** Called when the activity is first created. */
EditText editText1;
EditText editText2;
Button button ;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
button = (Button) findViewById(R.id.button1);
button.setOnClickListener( new OnClickListener() {

public void onClick(View v) {
// TODO Auto-generated method stub
editText1 = (EditText) findViewById(R.id.editText1);
editText2 = (EditText) findViewById(R.id.editText2);
String nameString = editText1.getText().toString();
String ageString = editText2.getText().toString();
Intent intent = new Intent();
intent.setClass(MainActivity. this, SubActivity. class);
Bundle bundle = new Bundle();
bundle.putString( "name", nameString);
bundle.putString( "age", ageString);
intent.putExtras(bundle);
startActivity(intent);

}
});
}
} package com.yanjun;

import android.app.Activity;

import android.os.Bundle;
import android.widget.TextView;

public class SubActivity extends Activity {

@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.main2);
TextView textView = (TextView) findViewById(R.id.textView1);
TextView textView2 = (TextView) findViewById(R.id.textView2);
Bundle bundle = this.getIntent().getExtras();
String nameString = bundle.getString( "name");
String ageString = bundle.getString( "age");
textView.setText( "输入姓名为--->" + nameString);
textView2.setText( "输入年龄为--->" + ageString);
}

}

更多相关文章

  1. android带输入框的Dialog
  2. TextInputLayout,让输入框更有灵性
  3. Android(安卓)验证码输入框 连续性粘贴 使用第三方包
  4. Google Android之使用XML布局
  5. Android(安卓)自绘输入框
  6. 弹出sub View在当前窗口
  7. Ubuntu 下配置使用Android(安卓)adb
  8. Android(安卓)软键盘问题总结
  9. eclipse ADT在线安装 https://dl-ssl.google.com/android/eclips

随机推荐

  1. 线性布局练习
  2. android 布局 LinearLayout
  3. 安卓9.0设置WIFI静态IP地址。
  4. Android 点击变色
  5. [置顶] 在Android程序代码中实现软件安装
  6. Android 线性布局 计算器
  7. android01
  8. 提高android文档加载速度
  9. Android 获取蓝牙Mac地址的正确方法
  10. Android startActivityForResult unfortu