Java listview中的Mapview(litemode)仅显示一个地图
使用此代码,仅显示第二项的映射。 所有地图都有谷歌标志(左下角)和在谷歌地图中打开地图的按钮(右下角),但其余的都是空白。 在向下滚动和向上滚动后,该图标也会消失 现在所有的地图都加载了相同的地址,但这显然会改变 我的另一个选择是使用静态贴图,但我想知道litemode mapview是否可以工作 CustomGrid.javaJava listview中的Mapview(litemode)仅显示一个地图,java,android,android-listview,android-mapview,Java,Android,Android Listview,Android Mapview,使用此代码,仅显示第二项的映射。 所有地图都有谷歌标志(左下角)和在谷歌地图中打开地图的按钮(右下角),但其余的都是空白。 在向下滚动和向上滚动后,该图标也会消失 现在所有的地图都加载了相同的地址,但这显然会改变 我的另一个选择是使用静态贴图,但我想知道litemode mapview是否可以工作 CustomGrid.java public class CustomGrid extends BaseAdapter{ private Context mContext; Bundl
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\u 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>
谢谢。我想你说的是这种情况。您是否正确添加了API密钥 仅当您单击标记时,方向和地图徽标才会显示 添加调试/发布 在 编辑:工作样本 使用谷歌地图API“Lite模式”(静态地图)、RecyclerView/CardView和材质设计风格(AppCompat)的地图列表