【发布时间】:2019-07-20 05:52:41
【问题描述】:
我想以英语和本地语言显示位置名称,例如 android 中的地图应用程序显示。
public class MapsActivity extends FragmentActivity implements OnMapReadyCallback {
private final static String TAG = MapsActivity.class.getSimpleName();
private GoogleMap mMap;
private SupportMapFragment mapFragment;
private String language = "bn";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_maps);
Locale locale = new Locale(language);
Locale.setDefault(locale);
Configuration config = new Configuration();
if(Build.VERSION.SDK_INT>Build.VERSION_CODES.JELLY_BEAN){
config.setLocale(locale);
getContext().createConfigurationContext(config);
}else { //deprecated
config.locale = locale;
getResources().updateConfiguration(config, getResources().getDisplayMetrics());
}
// Obtain the SupportMapFragment and get notified when the map is ready to be used.
mapFragment = (SupportMapFragment) getSupportFragmentManager().findFragmentById(R.id.map);
mapFragment.getMapAsync(this);
}
@Override
public void onMapReady(GoogleMap googleMap) {
mMap = googleMap;
LatLng dhaka = new LatLng(23.8103, 90.4125);
mMap.addMarker(new MarkerOptions().position(dhaka));
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(dhaka,10f));
}
}
但是当我运行此代码时,地图中的所有位置名称都是英文的。但我想要这样的输出
here 位置名称同时使用英语和孟加拉语。
【问题讨论】:
标签: android google-maps android-studio sdk