本文介绍了SupportMapFragment上DialogFragment的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要嵌入一个 SupportMapFragment
在对话框
。这是最好的,我能想到的:
公共类SupportMapFragmentDialog扩展DialogFragment {
私人最终SupportMapFragment片段;
公共SupportMapFragmentDialog(){
片段=新SupportMapFragment();
setTargetFragment(片段,1);
}
@覆盖
公共查看onCreateView(最终LayoutInflater充气,
最后的ViewGroup容器中,最后包savedInstanceState){
返回fragment.onCreateView(充气,容器,savedInstanceState);
}
公共SupportMapFragment getFragment(){
返回片段;
}
}
然而,当我把这个:
最后SupportMapFragmentDialog对话框=新SupportMapFragmentDialog();
dialog.show(getSupportFragmentManager(),历史一);
我得到这样的:
我能做些什么,看看在对话框的地图吗?
该应用程序有另一个 SupportMapFragment
正在创造奇迹,所以它没有任何与配置。
解决方案
在最后,我结束了在一个普通的对话框使用
图形页面
code>,而不是 SupportMapFragment
这是我的code:
决赛历史一H = adapter.getItem(ARG2 - 1);
如果(mv.getParent()!= NULL){
((的ViewGroup)mv.getParent())removeView(MV)。
}
最后一个对话框D =新的对话框(HistorialScreen.this);
。d.getWindow()clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
d.requestWindowFeature(Window.FEATURE_NO_TITLE);
d.setContentView(MV);
mv.getMap()清()。
。mv.getMap()moveCamera(CameraUpdateFactory.newLatLngZoom(h.getPosicion(),17));
最后MarkerOptions选项=新MarkerOptions();
options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_CYAN));
options.position(h.getPosicion());
。mv.getMap()addMarker(选件);
d.show();
和它的作品如预期。
I need to embed aSupportMapFragment
in aDialog
. This is the best I could think of:
public class SupportMapFragmentDialog extends DialogFragment {
private final SupportMapFragment fragment;
public SupportMapFragmentDialog() {
fragment = new SupportMapFragment();
setTargetFragment(fragment, 1);
}
@Override
public View onCreateView(final LayoutInflater inflater,
final ViewGroup container, final Bundle savedInstanceState) {
return fragment.onCreateView(inflater, container, savedInstanceState);
}
public SupportMapFragment getFragment() {
return fragment;
}
}
However, when I call this:
final SupportMapFragmentDialog dialog = new SupportMapFragmentDialog();
dialog.show(getSupportFragmentManager(), "Historico");
I get this:
What can I do to see the map on the Dialog?
The app has another SupportMapFragment
that is working wonders, so it doesn't have anything to do with the configuration.
解决方案
In the end I ended up usingMapView
in a regularDialog
instead ofSupportMapFragment
This is my code:
final Historico h = adapter.getItem(arg2 - 1);
if (mv.getParent() != null) {
((ViewGroup) mv.getParent()).removeView(mv);
}
final Dialog d = new Dialog(HistorialScreen.this);
d.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
d.requestWindowFeature(Window.FEATURE_NO_TITLE);
d.setContentView(mv);
mv.getMap().clear();
mv.getMap().moveCamera(CameraUpdateFactory.newLatLngZoom(h.getPosicion(), 17));
final MarkerOptions options = new MarkerOptions();
options.icon(BitmapDescriptorFactory.defaultMarker(BitmapDescriptorFactory.HUE_CYAN));
options.position(h.getPosicion());
mv.getMap().addMarker(options);
d.show();
And it works as intended.
这篇关于SupportMapFragment上DialogFragment的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!