我有这个问题:
当从地图上点击一个标记时,我需要开始一项活动,在片段上可视化;
这是我的 XML 的一部分:
<LinearLayout
android:id="@+id/mylayout"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="560" >
<fragment
android:id="@+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp"
android:clickable="true"
android:name="com.google.android.gms.maps.MapFragment"
/>
</LinearLayout>
当使用基于 Tabella 数据构建的一个标记时,我的 ACTIVITY1 桅杆调用 ACTIVITY2(此处未写):
@SuppressLint("NewApi")
public class ACTIVITY1 extends Activity {
. . . . . .
ArrayList<HashMap<String, String>> Tabella ();
. . . . . .
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.mylayout);
mapView = ((MapFragment) getFragmentManager().findFragmentById(R.id.mapview)).getMap();
. . . .
showmap(null);
. . . .
}
//prepare markers on map fragment
private void showMap(OnMarkerClickListener OnMarkerClickListener) {
arrM = new ArrayList<String> ();
mapView.setOnMarkerClickListener ( OnMarkerClickListener );
try {
for (int i=0 ; i<Tabella.size(); i++) {
HashMap<String, String> a = Tabella.get(i);
final String insegna = a.get("insegna");
String lat1 = a.get("latitudine");
String longi = a.get("longitudine");
if (lat1.equals("")) lat1 = "0.0";
if (longi.equals("")) longi = "0.0";
latitude = Double.parseDouble(lat1);
longitude = Double.parseDouble(longi);
cameraPosition = new CameraPosition.Builder()
.target(new LatLng(latitude,longitude))
.zoom(17) // Sets the zoom
.build();
marker = mapView.addMarker(new MarkerOptions()
.position(new LatLng(latitude, longitude))
.snippet("" )
.icon(BitmapDescriptorFactory.fromResource(R.drawable.iconpoi))
.title(insegna));
mapView.animateCamera(CameraUpdateFactory.newCameraPosition(cameraPosition));
marker.showInfoWindow();
arrM.add(marker.getId());
//mapView.setOnMarkerClickListener ( OnMarkerClickListener );
}
} catch (Exception e) {
e.printStackTrace();
}
}
//called when marker selected
public void onMarkerClick(Marker marker) {
. . .
Intent myIntent = new Intent(ACTIVITY1 .this,Activity2.class);
. .
myIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
ACTIVITY1 .this.startActivity(myIntent);
. .
}
}
onMarkerClick(Marker marker)
为什么不调用public void ?
怎么了 ?
谢谢