Advertisement
Guest User

Untitled

a guest
May 17th, 2012
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.77 KB | None | 0 0
  1. call onrestart/onresume when click on back button
  2. Intent intent = new Intent(Start.this, CitySelect.class);
  3. View view = TestActivity.group.getLocalActivityManager().startActivity("cityselect", intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
  4. TestActivity.group.replaceView(view);
  5.  
  6. public void replaceView(View v)
  7. {
  8. history.add(v);
  9. setContentView(v);
  10. }
  11.  
  12. @Override
  13. public void onBackPressed()
  14. {
  15. TestActivity.group.back();
  16. }
  17.  
  18. public void back()
  19. {
  20. if (history.size() > 0)
  21. {
  22. history.remove(history.size() - 1);
  23.  
  24. if (history.size() > 0)
  25. {
  26. View v = history.get(history.size() - 1);
  27. setContentView(v);
  28. }
  29.  
  30. else
  31. {
  32. finish();
  33. }
  34. }
  35.  
  36. else
  37. {
  38. finish();
  39. }
  40. }
  41.  
  42. Intent intent = new Intent(Start.this, CitySelect.class);
  43. View view = TestActivity.group.getLocalActivityManager().startActivity("cityselect", intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
  44. TestActivity.group.replaceView(view,"cityselect");
  45.  
  46. public void replaceView(View v, String activityId)
  47. {
  48. history.add(activityId);
  49. setContentView(v);
  50. }
  51.  
  52. public void back()
  53. {
  54. if (history.size() > 0)
  55. {
  56. history.remove(history.size() - 1);
  57.  
  58. if (history.size() > 0)
  59. {
  60. //View v = history.get(history.size() - 1);
  61. //setContentView(v);
  62.  
  63. LocalActivityManager manager = getLocalActivityManager();
  64. String lastId = mIdList.get(history.size()-1);
  65. Intent lastIntent = manager.getActivity(lastId).getIntent();
  66. Window newWindow = manager.startActivity(lastId, lastIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP));
  67. setContentView(newWindow.getDecorView());
  68.  
  69. }
  70.  
  71. else
  72. {
  73. finish();
  74. }
  75. }
  76.  
  77. else
  78. {
  79. finish();
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement