DEMO 木有注视 吼吼 ~~~
package com.isoftstone.cry;
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 StartActivityForResult_Next extends Activity
{
private Button btn ;
private EditText username,password ;
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.a_intent_01);
//get Instance
btn = (Button)findViewById(R.id.ai_button1);
username = (EditText)findViewById(R.id.ai_username_ed01);
password = (EditText)findViewById(R.id.ai_psd_editText2);
btn.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
Bundle bundle = new Bundle();
bundle.putString("username",username.getText().toString());
bundle.putString("password",password.getText().toString());
Intent intent = new Intent(StartActivityForResult_Next.this,
StartActivityForResult_Next2.class);
intent.putExtras(bundle);
startActivityForResult(intent, 0);
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{
// TODO Auto-generated method stub
Bundle bundle = data.getExtras();
String _username = bundle.getString("username");
String _password = bundle.getString("password");
username.setText(_username);
password.setText(_password);
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/ai_textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="username" />
<EditText
android:id="@+id/ai_username_ed01"
android:layout_width="match_parent"
android:layout_height="wrap_content">
</EditText>
<TextView
android:id="@+id/ai_textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="password" />
<EditText
android:id="@+id/ai_psd_editText2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPassword" />
<Button
android:id="@+id/ai_button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="下一步" />
</LinearLayout>
package com.isoftstone.cry;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
public class StartActivityForResult_Next2 extends Activity
{
private Button btn ;
@Override
protected void onCreate(Bundle savedInstanceState)
{
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.a_intent_02);
btn = (Button)findViewById(R.id.ai_button02);
btn.setOnClickListener(new View.OnClickListener()
{
@Override
public void onClick(View v)
{
// TODO Auto-generated method stub
Intent intent = getIntent();
//设置返回结果
StartActivityForResult_Next2.this.setResult(0,intent);
//结束当前activity
StartActivityForResult_Next2.this.finish();
}
});
}
}
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:id="@+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Email" />
<EditText
android:id="@+id/ai_ditText01"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textEmailAddress" >
</EditText>
<TextView
android:id="@+id/ai_textView02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="mobile" />
<EditText
android:id="@+id/ai_editText02"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="phone" />
<Button
android:id="@+id/ai_button02"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="上一步" />
</LinearLayout>