I just went through a similar problem and I came up with the following solution. By the way, now in game services there is a google map lite mode.
: https://github.com/vinirll/MapListView
, ListView BaseAdapter, getView. getView:
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if ( convertView == null )
convertView = new CustomItem(mContext,myLocations.get(position));
return convertView;
}
CustomItem - FrameLayout, .
public class CustomItem extends FrameLayout {
public int myGeneratedFrameLayoutId;
public CustomItem(Context context,Location location) {
super(context);
myGeneratedFrameLayoutId = 10101010 + location.id;
LayoutInflater inflater = ((Activity) context).getLayoutInflater();
FrameLayout view = (FrameLayout) inflater.inflate(R.layout.my_custom_item,null);
FrameLayout frame = new FrameLayout(context);
frame.setId(myGeneratedFrameLayoutId);
int height = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 150, getResources().getDisplayMetrics());
LayoutParams layoutParams = new LayoutParams(LayoutParams.MATCH_PARENT,height);
frame.setLayoutParams(layoutParams);
view.addView(frame);
GoogleMapOptions options = new GoogleMapOptions();
options.liteMode(true);
MapFragment mapFrag = MapFragment.newInstance(options);
mapFrag.getMapAsync(new MyMapCallback(location.lat,location.lng));
FragmentManager fm = ((Activity) context).getFragmentManager();
fm.beginTransaction().add(frame.getId(),mapFrag).commit();
addView(view);
}