나는 비슷한 문제를 겪었으며 다음 해결책을 생각해 냈습니다. 그건 그렇고, 지금 재생 서비스는 구글 맵 라이트 모드가 있습니다. 이제 당신이 BaseAdapter를 사용하여 ListView에 있다고 가정하자 https://github.com/vinirll/MapListView
, 그래서 당신은 당신의 getView 메소드를 오버라이드 (override) :
당신은 전체 예를 볼 수 있습니다. 이것이 내 getView의 모습입니다.
@Override
public View getView(int position, View convertView, ViewGroup parent) {
if (convertView == null)
convertView = new CustomItem(mContext,myLocations.get(position));
return convertView;
}
여기서 class CustomItem은 내 행을 나타내는 FrameLayout입니다.
public class CustomItem extends FrameLayout {
public int myGeneratedFrameLayoutId;
public CustomItem(Context context,Location location) {
super(context);
myGeneratedFrameLayoutId = 10101010 + location.id; // choose any way you want to generate your view 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);
//Create the the class that implements OnMapReadyCallback and set up your map
mapFrag.getMapAsync(new MyMapCallback(location.lat,location.lng));
FragmentManager fm = ((Activity) context).getFragmentManager();
fm.beginTransaction().add(frame.getId(),mapFrag).commit();
addView(view);
}
감사합니다. –
부풀린보기가 FrameLayout인데 왜 새 FrameLayout을 만드나요? 조금 두 배가 ... – Glenn85
public static int myGeneratedFrameLayoutId = 10101010; 이것은 매우 못생긴다 –