Show a MapView in a custom dialog?
I have a custom dialog with a mapview in the xml...
The dialog shows great without the mapview.
I get this error with the mapview MapViews can only be created inside instances of MapActivity.
How can I implement a mapview in a custom dialog?
Here is the simple code
public class Upload extends MapActivity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.upload_acti开发者_如何学Cvity);
Button selectPoint = (Button) findViewById(R.id.selectPoint);
selectPoint.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//showMapDialog();
Dialog dialog = new Dialog(Upload.this);
dialog.setTitle("Select Map Point");
dialog.setCancelable(true);
dialog.setContentView(R.layout.map_dialog);
dialog.show();
}
});
}
}
Your main activity needs to extend MapActivity.
public class HelloGoogleMaps extends MapActivity {
Rather than just extending Activity
**EDIT, try this:
MapView m = (MapView) findViewById(R.id.YourMapView);
dialog.setContentView(m);
精彩评论