// /聲明定位回調監聽器
AMapLocationListener mLocationListener = new AMapLocationListener() {
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (aMapLocation != null) {
if (aMapLocation.getErrorCode() == 0) {
mTvicon.setText(("獲取當前定位結果來源:"+aMapLocation.getLocationType()
+"/n獲取緯度:"+aMapLocation.getLatitude()+
"/n獲取經度:"+aMapLocation.getLongitude()+
"/n獲取精度信息:"+aMapLocation.getAccuracy()+
"/n地址;"+aMapLocation.getAddress()+
"/n國家信息:"+aMapLocation.getCountry()+
"/n省信息"+aMapLocation.getProvince()+
"/n城市信息"+aMapLocation.getCity()));
} else {
//定位失敗時,可通過ErrCode(錯誤碼)信息來確定失敗的原因,errInfo是錯誤信息,詳見錯誤碼錶。
Log.e("AmapError","location Error, ErrCode:" +
aMapLocation.getErrorCode() + ", errInfo:" +
aMapLocation.getErrorInfo());
ToastUtil.ShortToast("123456");
}
}
}
};
輸出的結果是不換行的"/n"也沒轉換
正確代碼如下:
// /聲明定位回調監聽器
AMapLocationListener mLocationListener = new AMapLocationListener() {
@Override
public void onLocationChanged(AMapLocation aMapLocation) {
if (aMapLocation != null) {
if (aMapLocation.getErrorCode() == 0) {
// mTvicon.setText(("獲取當前定位結果來源:"+aMapLocation.getLocationType()
// +"/n獲取緯度:"+aMapLocation.getLatitude()+
// "/n獲取經度:"+aMapLocation.getLongitude()+
// "/n獲取精度信息:"+aMapLocation.getAccuracy()+
// "/n地址;"+aMapLocation.getAddress()+
// "/n國家信息:"+aMapLocation.getCountry()+
// "/n省信息"+aMapLocation.getProvince()+
// "/n城市信息"+aMapLocation.getCity()));
StringBuffer sb = new StringBuffer(256);
sb.append("獲取當前定位結果來源:");
sb.append(aMapLocation.getLocationType());
sb.append("\n獲取緯度:");
sb.append(aMapLocation.getLatitude());
sb.append("\n獲取經度:");
sb.append(aMapLocation.getLongitude());
sb.append("\n獲取精度信息:");
sb.append(aMapLocation.getAccuracy());
sb.append("\n地址;");
sb.append(aMapLocation.getAddress());
sb.append("\n國家信息:");
sb.append(aMapLocation.getCountry());
sb.append("\n省信息");
sb.append(aMapLocation.getProvince());
mTvicon.setText(sb.toString());
} else {
//定位失敗時,可通過ErrCode(錯誤碼)信息來確定失敗的原因,errInfo是錯誤信息,詳見錯誤碼錶。
Log.e("AmapError","location Error, ErrCode:" +
aMapLocation.getErrorCode() + ", errInfo:" +
aMapLocation.getErrorInfo());
ToastUtil.ShortToast("123456");
}
}
}
};
這樣就上線自動換行了!!如果解決了你 的問題給個贊吧^@^!