Minutes to teach you integrated immersive slide-off activity

Source: Internet
Author: User

Online Search slide off activity, are very similar, even if there is no complete demo, said integration is simple, and so you will know. Personal habits, before writing a blog like first
1. First import into your project in the form of a project
2. Then in the activity you want to slide into the integration swipebackactivity, note that as long as the integration is good, and nothing else you write, you can realize the slide-off. The following code is listed: Mainactivity.java
  
 
  1. public class MainActivity extends AppCompatActivity {
  2. private TextView textView;
  3. @Override
  4. protected void onCreate(Bundle savedInstanceState) {
  5. super.onCreate(savedInstanceState);
  6. setContentView(R.layout.activity_main);
  7. textView = (TextView) findViewById(R.id.text);
  8. }
  9. public void click(View view) {
  10. if (view.getId() == R.id.button) {
  11. startActivity(new Intent(MainActivity.this, SecondActivity.class));
  12. } else {
  13. startActivityForResult(new Intent(MainActivity.this, ThirdActivity.class), 1);
  14. }
  15. }
  16. @Override
  17. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  18. String result = data.getStringExtra("result");
  19. if (requestCode == 1 && resultCode == 0) {
  20. textView.setText(result);
  21. }
  22. }
  23. }
Secondactivity.java
  
 
  1. public class SecondActivity extends SwipeBackActivity {
  2. @Override
  3. protected void onCreate(Bundle savedInstanceState) {
  4. super.onCreate(savedInstanceState);
  5. setContentView(R.layout.activity_second);
  6. }
  7. }
Thirdactivity.java
  
 
  1. public class ThirdActivity extends SwipeBackActivity {
  2. @Override
  3. protected void onCreate(Bundle savedInstanceState) {
  4. super.onCreate(savedInstanceState);
  5. setContentView(R.layout.activity_third);
  6. }
  7. @Override
  8. public void dothingBeforeFinish() {//这里是你要返回一些数据个启动的那个Activity,你可以在此做操作
  9. super.dothingBeforeFinish();
  10. Intent intent = new Intent();
  11. intent.putExtra("result", "来自ThirdActivity返回的值");
  12. setResult(0, intent);
  13. }
  14. }
The code is not very simple, so it is easy to achieve an immersive slide-off. As for the slide-by activity status bar Why is it gray, because I wrote dead in swipebackactivity, you can modify this color.
Setupstatusbarview (ActivitycontentlayoutColor.) Parsecolor ("#cccccc")) ;
OK, here is the GitHub source code, like please start, fork. Https://github.com/DyncKathline/SwipeBackLayout

Reprint Please indicate the source, thank you!





From for notes (Wiz)

Minutes to teach you integrated immersive slide-off activity

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.