Android应用开发视频教程-第1季

Android应用开发视频教程-第1季

5 (35人评价)
  • 课时:(50)

  • 学员:(743)

  • 浏览:(20912)

  • 加入课程

1.5_Activity值传递的笔记

相关课时: 笔记详情:
//mainActivity public class MainActivity extends Activity { private EditText edit; private Button button; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); edit = (EditText) this.findViewById (R.id.eidt); button = (Button) this.findViewById(R.id.but); button.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View arg0) { String s =edit.getText().toString(); Intent intent = new Intent(MainActivity.this,FindEdit.class); Bundle bundle = new Bundle(); bundle.putString("edit", s); intent.putExtra("bundle", bundle); startActivity(intent); } }); } } //跳转的Activity public class FindEdit extends Activity{ private TextView text; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.findedit_activity); text = (TextView) findViewById (R.id.text); Intent intent = getIntent(); Bundle bundle = intent.getBundleExtra("bundle"); String s = bundle.getString("edit"); text.setText(s); } }
0 0

你感兴趣的课程

8万+浏览/ 916学员/ 4.5评分
免费
6万+浏览/ 177学员/ 5评分
免费
6万+浏览/ 972学员/ 4.8评分
免费