2010-06-15 288 views

回答

9

您可以沿着数据传递的临时演员在启动第二个活动的意图:

Intent myIntent = new Intent(view.getContext(), NextActivity.class); 
myIntent.putExtra("extra", id); 
startActivityForResult(myIntent, 0); 

在您的个人资料活动的onCreate方法,您可以访问其它功能:

int id = getIntent().getStringExtra("extra");  

如果您对于Android来说是新的,它可能有助于阅读开发人员文档中的示例,例如notepad tutorial.

3

注册onClickListener作为按钮,并且p通过将所需数据添加到意图中来分析所需数据。

Button button = (Button) findViewById(R.id.button); 
button.setOnClickListener(new OnClickListener() { 

      @Override 
      public void onClick(View v) { 
          Intent intent = new Intent(Activity1.this, Activity2.class); 
          intent.putExtra("extra", data); 
          startActivity(intent); 
      }); 

您可以通过

String extra = getIntent().getStringExtra("extra"); 
相关问题