私はフラグメントを持っています:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_map_google_drawer"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/fragments_map_google"
android:layout_width="match_parent"
android:layout_height="match_parent"
class="ru.my_app.TransparentSupportMapFragment" />
</android.support.v4.widget.DrawerLayout>
およびクラス:
public class TransparentSupportMapFragment extends SupportMapFragment {
public TransparentSupportMapFragment() {
// SupportMapFragment sp;
super();
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup view, Bundle savedInstance) {
View layout = super.onCreateView(inflater, view, savedInstance);
FrameLayout frameLayout = new FrameLayout(getActivity());
frameLayout.setBackgroundColor(getResources().getColor(android.R.color.transparent));
((ViewGroup) layout).addView(frameLayout, new ViewGroup.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));
return layout;
}
}
そして、私SherlockFragmentActivity
はマップフラグメントを取得しようとしています:
map = ((TransparentSupportMapFragment) getSupportFragmentManager()
.findFragmentById((R.id.fragments_map_google))).getMap();
このコードは、2.3、HTS One S with 4.0、およびその他のデバイスで正常に動作します。しかし、4.1.4 を搭載した Samsung Galaxy S III または 4.1.2 を搭載した Sonu Xperia Z ではmap
無効です。
なぜか教えてくれますか?=/