private void startLocation() {
mLocationClient.start();
mLocationClient.requestLocation();
mLocationClient.registerLocationListener(new BDLocationListener() {
@Override
public void onReceiveLocation(BDLocation bdLocation) {
if (bdLocation == null) {
return;
}
StringBuffer sb = new StringBuffer(256);
sb.append(bdLocation.getAddrStr());
mEditLocation.setText(sb.toString());
StringBuffer sbcity = new StringBuffer(256);
sbcity.append(bdLocation.getCity());
StringBuffer code = new StringBuffer(256);
code.append(bdLocation.getLocType());
Log.i("error code", code.toString());
String cityname = sbcity.toString();
String mcityname = cityname.substring(0, cityname.length() - 1);
//把汉语转化为拼音
String mycityname=ChineseToPinYin.getPinYin(mcityname);
//根据位置获取天气
getWeather(mycityname);
mLocationClient.stop();
city=mycityname;
}
});
}
最后的city是我定义的 全局变量,但是这样传参 全局变量是得不到值的 ,这是在监听器的匿名内部类里传参给全局变量 该怎么办