0

Sherlock ActionBar 및 Support Library가 포함 된 Android 프로젝트가 있습니다. 이 SherlockFragmentActivity의에서 onCreate에서 나는 2 개 탭 액션 바 초기화 : 나는 첫 번째 탭으로 돌아 갈 때Android Sherlock ActionBar 탭에서 SupportMapFragment를 제대로 분리 할 수 ​​없습니다.

private void configureActionBar(){ 
    ActionBar actionBar = getSupportActionBar(); 
    actionBar.setDisplayShowTitleEnabled(false); 
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); 
    ActionBar.Tab tab = actionBar.newTab() 
      .setText("Events") 
      .setTabListener(new TabListener<SampleListFragment>(
        this, "events", SampleListFragment.class)); 
    actionBar.addTab(tab); 

    tab = actionBar.newTab() 
      .setText("Map") 
      .setTabListener(new TabListener<SupportMapFragment>(
        this, "map", SupportMapFragment.class)); 
    actionBar.addTab(tab); 
} 

문제는 화면이 회색으로지도 컨트롤이 검은 색입니다. 장치 화면에서 \을 끄면 Map이 완전히 제거되고 모든 것이 정상입니다.

public class TabListener<T extends Fragment> implements ActionBar.TabListener { 
private Fragment mFragment; 
private final Activity mActivity; 
private final String mTag; 
private final Class<T> mClass; 

/** Constructor used each time a new tab is created. 
* @param activity The host Activity, used to instantiate the fragment 
* @param tag The identifier tag for the fragment 
* @param clz The fragment's Class, used to instantiate the fragment 
*/ 
public TabListener(Activity activity, String tag, Class<T> clz) { 
    mActivity = activity; 
    mTag = tag; 
    mClass = clz; 
} 

/* The following are each of the ActionBar.TabListener callbacks */ 

public void onTabSelected(ActionBar.Tab tab, FragmentTransaction ft) { 
    // Check if the fragment is already initialized 
    if (mFragment == null) { 
     // If not, instantiate and add it to the activity 
     mFragment = Fragment.instantiate(mActivity, mClass.getName()); 
     ft.add(android.R.id.content, mFragment, mTag); 
    } else { 
     // If it exists, simply attach it in order to show it 
     ft.attach(mFragment); 
    } 
} 

public void onTabUnselected(ActionBar.Tab tab, FragmentTransaction ft) { 
    if (mFragment != null) { 
     // Detach the fragment, because another one is being attached 
     ft.detach(mFragment); 
    } 
} 

public void onTabReselected(ActionBar.Tab tab, FragmentTransaction ft) { 
    // User selected the already selected tab. Usually do nothing. 
} 

} 나는 그것이에 문제 것을 발견했다 포럼을 검색 한 후하는 SlidingMenu와 SupportMapFragment을 구현할 때

답변

0

내가 한 번 유사 문제를 건너 온 :

TabListener 구현은 구글 매뉴얼에서입니다 서피스 뷰 SurfaceView과이 방법으로 투명 맵을 설정하여 고정 될 수 있다는 :

private void setMapTransparent(ViewGroup group) { 
     int childCount = group.getChildCount(); 
     for (int i = 0; i < childCount; i++) { 
      View child = group.getChildAt(i); 
      if (child instanceof ViewGroup) { 
       setMapTransparent((ViewGroup) child); 
      } else if (child instanceof SurfaceView) { 
       child.setBackgroundColor(0x00000000); 
      } 
     } 
    } 

그냥에서 해당 메소드를 호출하여 SupportMapFragment의 onCreateView입니다.