我对安卓是个新手。我想将用户输入从一个活动发送到另一个活动,当我输入文本并点击send text按钮时,我返回到主活动,但在结果应该在的textview中得到“null”。已经看了其他答案,但仍然没有快乐!主活动,从其他活动接收用户输入TextView textView1; public class MainActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); textView1 = (TextView) findViewById(R.id.textView1); } public void relativeLayout(View view) { // Create The Intent and Start The Activity to get The message Intent relativeLayoutIntent=new Intent(MainActivity.this,ExplicitRelativeLayout.class); startActivityForResult(relativeLayoutIntent, 2); } @Override protected void onActivityResult(int requestCode,int resultCode,Intent data) { super.onActivityResult(requestCode, resultCode, data); // check if the request code is same as what is passed. here it is 2 if(requestCode==2) { if(null!=data) { // fetch the message String String name = data.getStringExtra("name"); String email = data.getStringExtra("email"); String phone = data.getStringExtra("phone"); // Set the message string in textView textView1.setText("Name: " + name + "" + "\n" + "Email: " + email + " " + "\n" +"Phone:" + phone ); }相对延迟活动,用户输入文本public class ExplicitRelativeLayout extends AppCompatActivity { EditText setName; EditText setEmail; EditText setPhone;@Overrideprotected void onCreate(Bundle savedInstanceState){ super.onCreate(savedInstanceState); setContentView(R.layout.explicitrelativelayout); // Get the reference of Edit Text setName = (EditText) findViewById(R.id.setName); setEmail = (EditText) findViewById(R.id.setEmail); setPhone = (EditText) findViewById(R.id.setPhone);}public void sendText (View views){ // get the Entered message String name=setName.getText().toString(); String email= setEmail.getText().toString(); String phone=setPhone.getText().toString(); Intent intentmessage = new Intent(); // put the message in Intent intentmessage.putExtra("Name:",name); intentmessage.putExtra("Email:",email); intentmessage.putExtra("Phone:",phone); // Set The Result in Intent setResult(2,intentmessage); // finish The activity finish();}} 最佳答案 似乎你在两个类中使用的密钥不匹配使用而不是intentmessage.putExtra("name",name);关于android - Android开始 Activity 的结果,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/33780950/