我尝试使用OnActivityCreated调用片段中的其他Activity,我的代码有什么问题。它不起作用。请帮助,谢谢。 提取代码如下所示
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1)
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
setContentView(R.layout.activity_main);
ArrayAdapter<String> adapter = new ArrayAdapter<String> (getActionBar().getThemedContext(), android.R.layout.simple_list_item_1, data);
FragmentManager fm = getChildFragmentManager();
fragment = (MapFragment) fm.findFragmentById(R.id.map);
if (fragment == null) {
fragment = MapFragment.newInstance();
fm.beginTransaction().replace(R.id.map, fragment).commit();
}
}
@Override
public void onResume() {
super.onResume();
if (map == null) {
map = fragment.getMap();
map.addMarker(new MarkerOptions().position(new LatLng(0, 0)));
}
}
}