Guest User

Untitled

a guest
Jul 19th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.98 KB | None | 0 0
  1. private String mFillAddrField = "";
  2. ...
  3. @Override
  4. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  5. super.onActivityResult(requestCode, resultCode, data);
  6. if (resultCode == RESULT_OK) {
  7. if(data == null) {
  8. ...
  9. } else {
  10. Bundle b = data.getExtras(); //DATA retrieved from second activity successfully
  11. mFillAddrField = b.getString("address");
  12. }
  13. }
  14. }
  15.  
  16. ...
  17. public void displayAddScreen() {
  18. AlertDialog.Builder alert = new AlertDialog.Builder(this);
  19.  
  20. alert.setTitle("Create a new Grocery Store");
  21. alert.setMessage("Create a new store by filling out the form below.");
  22.  
  23. LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
  24. View layout = inflater.inflate(R.layout.newstore_dialog, (ViewGroup) findViewById(R.id.nsd_root));
  25.  
  26. final EditText nameField = (EditText) layout.findViewById(R.id.nsd_et_name);
  27. final EditText addrField = (EditText) layout.findViewById(R.id.nsd_et_address);
  28. final Button addrSelect = (Button) layout.findViewById(R.id.nsd_b_address);
  29.  
  30. alert.setView(layout);
  31.  
  32. addrSelect.setOnClickListener(new OnClickListener() {
  33.  
  34. @Override
  35. public void onClick(View v) {
  36. //Open MAPS API return me an address
  37. //Save address to text field
  38. Intent i = new Intent(getApplicationContext(), GroceryMapActivity.class);
  39. startActivityForResult(i,0);
  40. addrField.setText(mFillAddrField); //OFFENDING CODE HERE
  41. }
  42. });
  43.  
  44. private String mFillAddrField = "";
  45. EditText addrField;
  46. ...
  47. @Override
  48. protected void onActivityResult(int requestCode, int resultCode, Intent data) {
  49. super.onActivityResult(requestCode, resultCode, data);
  50. if (resultCode == RESULT_OK) {
  51. if(data == null) {
  52. ...
  53. } else {
  54. Bundle b = data.getExtras(); //DATA retrieved from second activity successfully
  55. mFillAddrField = b.getString("address");
  56. addrField.setText(mFillAddrField);
  57. }
  58. }
  59. }
  60.  
  61. ...
  62. public void displayAddScreen() {
  63. AlertDialog.Builder alert = new AlertDialog.Builder(this);
  64.  
  65. alert.setTitle("Create a new Grocery Store");
  66. alert.setMessage("Create a new store by filling out the form below.");
  67.  
  68. LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
  69. View layout = inflater.inflate(R.layout.newstore_dialog, (ViewGroup) findViewById(R.id.nsd_root));
  70.  
  71. final EditText nameField = (EditText) layout.findViewById(R.id.nsd_et_name);
  72. addrField = (EditText) layout.findViewById(R.id.nsd_et_address);
  73.  
  74. final Button addrSelect = (Button) layout.findViewById(R.id.nsd_b_address);
  75.  
  76. alert.setView(layout);
  77.  
  78. addrSelect.setOnClickListener(new OnClickListener() {
  79.  
  80. @Override
  81. public void onClick(View v) {
  82. //Open MAPS API return me an address
  83. //Save address to text field
  84. Intent i = new Intent(getApplicationContext(), GroceryMapActivity.class);
  85. startActivityForResult(i,0);
  86. }
  87. });
Add Comment
Please, Sign In to add comment