我现在用的是地缘codeR类来获取通过以下code的多个位置的对象:
I am using the Geocoder class to fetch multiple location objects by using the following code:
Geocoder geocoder = new Geocoder(this, Locale.getDefault());
List<Address> addresses = geocoder.getFromLocation(LATITUDE, LONGITUDE, 3);
Address[] addresses_array = new Address[addresses.size()];
addresses.toArray(addresses_array);
for( int i = 0; i < addresses_array.length; i++ ){
//create location object here
locOBJ.setLatitude(LATITUDE);
locOBJ.setLongitude(LONGITUDE);
}
此外,forloop里面,我想dymanically创建位置对象添加到一个数组;
In addition, inside the forloop, I am trying to dymanically create location objects to add to an array;
我怎样才能创建空白位置对象?
How can I create blank location objects ?
假设你指的 android.location.Location
用这需要一个提供字符串的构造函数,并将其设置到任何你想要的。
Assuming you refer to android.location.Location
use the constructor which takes a provider string and set it to whatever you want.