这是我的问题:我有一个具有 3 个视图的页面适配器,左侧用于本地化用户并使用已本地化的地址的不同元素填充一些 editText 字段,这是方法:
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;
}
问题是,如果本地化不够精确,我希望用户能够编辑editText,但是当我编辑这些字段并且我回到我的主要活动时(位置之一是左侧的位置)我的页面适配器,这个在中间,最后一个是正确的)我有一个按钮可以将我的活动中的所有数据保存到我的 SQLite 数据库中......一切正常,但是当我修改地址的 edditText 字段时从地址位置自动填充一些 setText 存储在我的数据库中的值仍然是我的 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();
...
我不明白 ?这是否意味着一旦 editText 填充了 .setText("...") 我们就不能再修改它了?