Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- private String mFillAddrField = "";
- ...
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (resultCode == RESULT_OK) {
- if(data == null) {
- ...
- } else {
- Bundle b = data.getExtras(); //DATA retrieved from second activity successfully
- mFillAddrField = b.getString("address");
- }
- }
- }
- ...
- public void displayAddScreen() {
- AlertDialog.Builder alert = new AlertDialog.Builder(this);
- alert.setTitle("Create a new Grocery Store");
- alert.setMessage("Create a new store by filling out the form below.");
- LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
- View layout = inflater.inflate(R.layout.newstore_dialog, (ViewGroup) findViewById(R.id.nsd_root));
- final EditText nameField = (EditText) layout.findViewById(R.id.nsd_et_name);
- final EditText addrField = (EditText) layout.findViewById(R.id.nsd_et_address);
- final Button addrSelect = (Button) layout.findViewById(R.id.nsd_b_address);
- alert.setView(layout);
- addrSelect.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- //Open MAPS API return me an address
- //Save address to text field
- Intent i = new Intent(getApplicationContext(), GroceryMapActivity.class);
- startActivityForResult(i,0);
- addrField.setText(mFillAddrField); //OFFENDING CODE HERE
- }
- });
- private String mFillAddrField = "";
- EditText addrField;
- ...
- @Override
- protected void onActivityResult(int requestCode, int resultCode, Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (resultCode == RESULT_OK) {
- if(data == null) {
- ...
- } else {
- Bundle b = data.getExtras(); //DATA retrieved from second activity successfully
- mFillAddrField = b.getString("address");
- addrField.setText(mFillAddrField);
- }
- }
- }
- ...
- public void displayAddScreen() {
- AlertDialog.Builder alert = new AlertDialog.Builder(this);
- alert.setTitle("Create a new Grocery Store");
- alert.setMessage("Create a new store by filling out the form below.");
- LayoutInflater inflater = (LayoutInflater) this.getSystemService(LAYOUT_INFLATER_SERVICE);
- View layout = inflater.inflate(R.layout.newstore_dialog, (ViewGroup) findViewById(R.id.nsd_root));
- final EditText nameField = (EditText) layout.findViewById(R.id.nsd_et_name);
- addrField = (EditText) layout.findViewById(R.id.nsd_et_address);
- final Button addrSelect = (Button) layout.findViewById(R.id.nsd_b_address);
- alert.setView(layout);
- addrSelect.setOnClickListener(new OnClickListener() {
- @Override
- public void onClick(View v) {
- //Open MAPS API return me an address
- //Save address to text field
- Intent i = new Intent(getApplicationContext(), GroceryMapActivity.class);
- startActivityForResult(i,0);
- }
- });
Add Comment
Please, Sign In to add comment