标签:
public class MainActivity extends AppCompatActivity {
private TextView textView;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
textView = (TextView) findViewById(R.id.text);
}
public void click(View view) {
if (view.getId() == R.id.button) {
startActivity(new Intent(MainActivity.this, SecondActivity.class));
} else {
startActivityForResult(new Intent(MainActivity.this, ThirdActivity.class), 1);
}
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
String result = data.getStringExtra("result");
if (requestCode == 1 && resultCode == 0) {
textView.setText(result);
}
}
}
public class SecondActivity extends SwipeBackActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_second);
}
}
public class ThirdActivity extends SwipeBackActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_third);
}
@Override
public void dothingBeforeFinish() {//这里是你要返回一些数据个启动的那个Activity,你可以在此做操作
super.dothingBeforeFinish();
Intent intent = new Intent();
intent.putExtra("result", "来自ThirdActivity返回的值");
setResult(0, intent);
}
}
setupStatusBarView(activity, contentLayout, Color.parseColor("#cccccc"));
标签:
原文地址:http://www.cnblogs.com/xiongxuesong/p/5845121.html