Используя этот код, отобразится только карта для второго элемента. На всех картах есть логотип google (внизу слева) и кнопка, чтобы открыть карту в GoogleMaps (внизу справа), но остальное пустое. После прокрутки вниз и обратно вверх, этот тоже исчезает.Mapview (litemode) в списке показывается только одна карта
В данный момент на всех картах загружаются одинаковые адреса.
Моим другим вариантом является использование статических карт, но хотелось бы узнать, может ли работать режим просмотра litemode.
CustomGrid.java
public class CustomGrid extends BaseAdapter{
private Context mContext;
Bundle savedInstanceState;
private GoogleMap map;
private final String[] eventname;
String finaldate;
static final LatLng HAMBURG = new LatLng(53.558, 9.927);
//private final int[] Imageid;
//public CustomGrid(Context c,String[] web,int[] Imageid) {
public CustomGrid(Context c, final Bundle b, String[] eventname, String[] date, String[] venue, String[] city, String[] state, String[] catA, String[] catB, String[] pricerange, Double[] price) {
mContext = c;
//this.Imageid = Imageid;
this.eventname = eventname;
this.savedInstanceState = b;
}
@Override
public int getCount() {
// TODO Auto-generated method stub
return eventname.length;
}
@Override
public Object getItem(int position) {
// TODO Auto-generated method stub
return null;
}
@Override
public long getItemId(int position) {
// TODO Auto-generated method stub
return 0;
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
View grid;
LayoutInflater inflater = (LayoutInflater) mContext
.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (convertView == null) {
grid = new View(mContext);
//grid = inflater.inflate(R.layout.grid_single, null);
//grid = inflater.inflate(R.layout.grid_single, parent, false);
grid = inflater.inflate(R.layout.grid_single, parent, false);
} else {
grid = (View) convertView;
}
/*
TextView textView_eventname = (TextView) grid.findViewById(R.id.grid_text_eventname);
TextView textView_location = (TextView) grid.findViewById(R.id.grid_text_location);
TextView textView_pricerange = (TextView) grid.findViewById(R.id.grid_text_pricerange);
*/
TextView textView_eventname = (TextView) grid.findViewById(R.id.event_name);
textView_eventname.setText(eventname[position]);
MapView mapView = (MapView) grid.findViewById(R.id.event_map);
mapView.onCreate(savedInstanceState);
map = mapView.getMap();
MapsInitializer.initialize(mContext);
map.addMarker(new MarkerOptions()
.position(HAMBURG)
.title("Me")
.icon(BitmapDescriptorFactory.fromResource(R.mipmap.ic_launcher)));
map.moveCamera(CameraUpdateFactory.newLatLngZoom(HAMBURG, 15));
return grid;
}
}
Функция, которая вызывает пользовательские сетки для создания плитки
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.event_grid);
CustomGrid adapter = new CustomGrid(EventGrid.this, savedInstanceState, eventname);
grid=(GridView)findViewById(R.id.grid);
grid.setAdapter(adapter);
}
grid_single.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:map="http://schemas.android.com/apk/res-auto"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
android:id="@+id/event_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#3E3E3E"
android:textStyle="bold" />
<com.google.android.gms.maps.MapView
android:id="@+id/event_map"
android:layout_width="wrap_content"
android:layout_height="120dp"
android:background="#3E3E3E"
android:textStyle="bold"
map:cameraZoom="13"
map:mapType="normal"
map:liteMode="true"/>
</LinearLayout>
Спасибо.