【发布时间】:2016-11-11 14:17:40
【问题描述】:
我在我的应用程序中使用 getChildFragmentManager(),我想在 Fragment OncreateView() 中调用下面的代码。任何人都可以帮助实现此功能,实际上我已经保留了代码,我在 Line 中遇到错误2号?
1. SupportPlaceAutocompleteFragment autocompleteFragment = (SupportPlaceAutocompleteFragment) getFragmentManager()
2. .findFragmentById(R.id.place_autocomplete_fragment);
3. autocompleteFragment.setOnPlaceSelectedListener(this);
4. autocompleteFragment.setHint("Select a Location");
错误: java.lang.NullPointerException:尝试调用虚拟方法 'void com.google.android.gms.location.places.ui.SupportPlaceAutocompleteFragment.setOnPlaceSelectedListener(com.google. android.gms.location.places.ui.PlaceSelectionListener)' 在空对象引用上 com.example.sample.fragments.LocationFragment.onCreateView(LocationFragment.java:2)
at
【问题讨论】:
标签: android google-maps google-places-api