2013-05-05 2 views
0

FragmentTransaction을 사용하여 작업에서 2 개의 조각을 전환하고 하나는 MapFragment로 전환하려고합니다.Fragment와 MapFragment 사이를 처음 전환 할 때 전체 화면이 잠깐 검은 색으로 변합니다.

첫 번째 전환에서 전체 화면이 매우 짧은 순간 검은 색으로 변합니다.

하지만 마지막 스위치에서 현상이 사라졌습니다.

다음은 데모 버전입니다. http://www.youtube.com/watch?v=FDf-LTZT9Wk

그리고 여기에는 내가 전환하는 일부 소스 코드가 있습니다.

XML :

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/my_container" 
android:layout_width="match_parent" 
android:layout_height="match_parent" ></RelativeLayout> 

활동

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.activity_main); 
    getSupportFragmentManager().beginTransaction().replace(R.id.my_container, new Fragment()) 
      .commit(); 
} 

@Override 
public boolean onOptionsItemSelected(MenuItem item) { 
    switch (item.getItemId()) { 
    case R.id.menu_change: 
     if (flag) { 
      flag = false; 
      getSupportFragmentManager().beginTransaction() 
        .replace(R.id.my_container, new Fragment()).commit(); 
     } else { 
      getSupportFragmentManager().beginTransaction() 
        .replace(R.id.my_container, SupportMapFragment.newInstance()).commit(); 
      flag = true; 
     } 
     break; 
    } 
    return super.onOptionsItemSelected(item); 
} 

나는 이런 일이 왜 이러한 현상의 이유를 알고 있다면 ...

을 실현, 또는 방법을 알 수 없다 그것을 해결, 가르쳐주세요!

감사합니다.

답변

관련 문제