[英]Eclipse showing error on MapFragment.getMap() line
Eclipse show an error on MapFragment.getMap()
line; Eclipse在
MapFragment.getMap()
行上显示错误; here is my source code: 这是我的源代码:
MapActivity : MapActivity:
public class MapActivity extends BaseActivity {
@SuppressLint("NewApi")
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// replace content_menu fragment with map fragment
FragmentTransaction fragTans = getFragmentManager().beginTransaction();
fragTans.replace(R.id.content_frame, new MapFragment());
fragTans.commit();
}
}
MapFragment MapFragment
public class MapFragment extends Fragment {
@SuppressWarnings("unchecked")
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Map setup
View mapView = inflater.inflate(R.layout.map_layout, null);
// Eclipse show me that getMap is not exist here
GoogleMap mapGoogle = ((MapFragment)getFragmentManager().findFragmentById(R.id.map_view)).getMap();
// ... customize my map , add marker ....
return mapView;
}
}
Best Regards 最好的祝福
view = inflater.inflate(R.layout.map_tab_fragment, container, false);
SupportMapFragment fm = (SupportMapFragment) getFragmentManager().findFragmentById(R.id.map);
map = fm.getMap();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.