我已經集成了新的谷歌地圖api v2片段在視圖尋呼機。當我從地圖選項卡(街道視圖屏幕)移動到第二個選項卡(客戶端詳細信息)時,顯示的黑色視圖將數據擴展爲片段。任何人都知道解決方案。ViewPager與谷歌地圖API v2變黑
截圖:
代碼:
ListingStreetViewFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View inflatedView = inflater.inflate(R.layout.map_view, container, false);
try {
MapsInitializer.initialize(getActivity());
} catch (GooglePlayServicesNotAvailableException e) {
// TODO handle this situation
}
markers = new Hashtable<String, String>();
mMapView = (MapView) inflatedView.findViewById(R.id.map);
mMapView.onCreate(mBundle);
mMapView.onResume();
setUpMapIfNeeded(inflatedView);
return inflatedView;
}
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
mBundle = savedInstanceState;
}
// mapping between map object with xml layout.
private void setUpMapIfNeeded(View inflatedView) {
if (mMap == null) {
mMap = ((MapView) inflatedView.findViewById(R.id.map)).getMap();
if (mMap != null) {
mMap.setInfoWindowAdapter(new CustomInfoWindowAdapter());
setUpMap();
}
}
}
//set location on map and show marker on random location
private void setUpMap() {
// random latitude and logitude
// Adding a marker
MarkerOptions marker = new MarkerOptions().position(
new LatLng(53.558, 9.927))
.title("Hello Maps ");
marker.snippet("dinet");
// changing marker color
marker.icon(BitmapDescriptorFactory
.defaultMarker(BitmapDescriptorFactory.HUE_BLUE));
mMap.addMarker(marker);
// Move the camera to last position with a zoom level
CameraPosition cameraPosition = new CameraPosition.Builder()
.target(new LatLng(53.558,
9.927)).zoom(16).build();
mMap.animateCamera(CameraUpdateFactory
.newCameraPosition(cameraPosition));
}
@Override
public void onResume() {
if (null != mMapView)
mMapView.onResume();
super.onResume();
}
@Override
public void onPause() {
super.onPause();
if (null != mMapView)
mMapView.onPause();
}
@Override
public void onDestroy() {
super.onDestroy();
if (null != mMapView)
mMapView.onDestroy();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
if (null != mMapView)
mMapView.onSaveInstanceState(outState);
}
@Override
public void onLowMemory() {
super.onLowMemory();
if (null != mMapView)
mMapView.onLowMemory();
}
ListingClientDetailFragment.java
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.client_detail, container, false);
initUi(rootView);
idval = ListingListFragment.cid;
System.out.println("SET: " + idval);
setValues();
return rootView;
}
protected void initUi(View v){
db = new Databasehelper(getActivity());
cDetail = new HashMap<String, String>();
tvName = (TextView)v.findViewById(R.id.tvName);
tvType = (TextView)v.findViewById(R.id.tvType);
tvStatus = (TextView)v.findViewById(R.id.tvStatus);
tvEmail = (TextView)v.findViewById(R.id.tvEmail);
tvPhone = (TextView)v.findViewById(R.id.tvPhone);
ivCall = (ImageView)v.findViewById(R.id.ivCall);
ivMsg = (ImageView)v.findViewById(R.id.ivMsg);
}
//get data from database and set into controls.
protected void setValues(){
cDetail = db.getClientDetail(idval);
tvName.setText(cDetail.get("name"));
tvType.setText(cDetail.get("type"));
tvStatus.setText(cDetail.get("status"));
tvEmail.setText(cDetail.get("email"));
tvPhone.setText(cDetail.get("phone"));
}
並且logcat中沒有錯誤顯示。所以,我不能從那裏追蹤它。
哪裏是你的代碼? – GrIsHu
請添加一些代碼或查看日誌貓,這可能是因爲api密鑰的身份驗證錯誤。 –
@GrIsHu現在檢查它.. – Riser