Ich erstelle eine OSMdroid Mapview in meiner MapActivity.java und ich möchte hinzufügen & Pop-ups - ich weiß nur, wie dies in .xml getan wird, aber da MapView keine .xml ich bin verwirrt, wie ich (Bild) Schaltflächen in meinem Java-Code platzieren kann.Schaltflächen über Mapview
@Override
public void onCreate(final Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Setup base map
final RelativeLayout rl = new RelativeLayout(this);
CloudmadeUtil.retrieveCloudmadeKey(getApplicationContext());
final MapView osmv = new MapView(this, 256);
myMapController = osmv.getController();
rl.addView(osmv, new RelativeLayout.LayoutParams(LayoutParams.FILL_PARENT,
LayoutParams.FILL_PARENT));
osmv.setBuiltInZoomControls(true);
osmv.setMultiTouchControls(true);
myLocationoverlay = new MyLocationOverlay(this, osmv);
//*snip* setup of map, mapcontrollers, tiles etc...
osmv.getOverlays().add(tilesOverlay);
osmv.getOverlays().add(myLocationoverlay);
this.setContentView(rl);
}
edit: ich über eine Taste rede wie
<ImageButton
android:id="@+id/map_goto_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@drawable/goto_location"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:id="@+id/goto_location" />
Da Sie die 'MapView' zu einem' RelativeLayout' hinzufügen, fügen Sie einfach alle anderen UI-Elemente zu diesem Container hinzu. Stellen Sie sicher, dass Sie diese hinzufügen, nachdem Sie die MapView hinzugefügt haben, sodass sie oben angezeigt werden. Sie können entweder alle UI-Elemente im Code einrichten oder sie in XML deklarieren und sie mit einem 'LayoutInflater' inflatieren. Vergessen Sie auch nicht, sie nach dem Erstellen/Aufblasen hinzuzufügen. –