Here is my problem : I have a pageadapter with 3 views, the left one is used to localize the user and fill in somes editText fields with the different elements of the address that was localized, here is the method :
private boolean getAddressLocation(Location location) {
if (location != null) {
lat = location.getLatitude();
longi = location.getLongitude();
Geocoder gc = new Geocoder(NoteReminder.this, Locale.getDefault());
try {
List<Address> addresses = gc.getFromLocation(lat, longi, 1);
if (addresses.size() > 0) {
Address address = (Address) addresses.get(0);
streetNumber = address.getAddressLine(0);
locality = address.getLocality();
postcode = address.getPostalCode();
country = address.getCountryName();
etCountry.setText(country, TextView.BufferType.EDITABLE);
etPostcode.setText(postcode, TextView.BufferType.EDITABLE);
etLocality.setText(locality, TextView.BufferType.EDITABLE);
etAddressText.setText(streetNumber, TextView.BufferType.EDITABLE);
return true;
}
} catch (Exception e) {
e.printStackTrace();
}
}
return false;
}
The problem is that I d like the user to be able to edit the editText if the localization wasn't precise enough BUT when I edit those fields and that i come back to my main activity (the location one was the one on the left of my pageadapter, this one is in the middle and the last one is the right one) I have a button to save all the datas from my activity into my SQLite database... Everything works fine but when i modify the eedditText fields of the address that were automaticaly filled in with some setText from the address location the values that are stored in my database are still the automatically filled in fields of my editText ...
...
etCountry = (EditText) findViewById(R.id.etCountry);
etPostcode = (EditText) findViewById(R.id.etPostcode);
etLocality = (EditText) findViewById(R.id.etLocality);
etAddressText = (EditText) findViewById(R.id.etAddressText);
display = etAddressText.getText() + "," + etLocality.getText() + "," + etPostcode.getText()
+ "," + etCountry.getText();
...
I don t understand ? Does it mean that onces the editText is filled with a .setText("...") we can't modifie it anymore ?
To verify: you seem to be implying that your string "display" is showing the old data. Is that the case?
Are you looking in the correct page of your PagerAdapter for those findViewById()s when you want to get the text out of the EditTexts?
Are you using a FragmentPagerAdapter? If your pager pages are Fragments, you may need to pass the information between them as their lifecycles change.