0
위도와 경도의 값을 EditText
으로 되 돌리고 싶습니다. Toast
을 사용하여 수행 할 수 있지만 EditText
을 통해 처리 할 수는 없습니다. 좋은 말 할 때, 당신은 단순히 당신의 활동은 LocationListener 구현할 수만큼 latEditText
및 lngEditText
변수가 클래스 넓은 범위를 가지고Android TextBox
// EditText latEditText = (EditText)findViewById(R.id.lat);
//EditText lngEditText = (EditText)findViewById(R.id.lng);
protected void showCurrentLocation(){
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
if (location != null){
String message = String.format(
"Current Location \n Longitude: %1$s \n Latitude: %2$s",
location.getLongitude(), location.getLatitude()
);
Toast.makeText(LayActivity.this, message,
Toast.LENGTH_LONG).show();
//latEditText.setText(nf.format(location.getLatitude()).toString());
//lngEditText.setText(nf.format(location.getLongitude()).toString());
}
}
private class MyLocationListener implements LocationListener{
@Override
public void onLocationChanged(Location location) {
// TODO Auto-generated method stub
String message = String.format(
"New Location \n Longitude: %1$s \n Latitude: %2$s",
location.getLongitude(), location.getLatitude()
);
Toast.makeText(LayActivity.this, message, Toast.LENGTH_LONG).show();
//latEditText.setText((int) location.getLatitude());
//lngEditText.setText((int) location.getLongitude());
}
왜 작동하는지 설명하고 싶을 수 있습니다. 즉,'setText'에'int'를 제공하는 것이 그것이 리소스 ID라는 것을 의미하기 때문입니다. – Eric