0

로그 캣에서 오류를 찾지보기 : 여기 E/FragmentManager(7158): No view found for id 0x7f05000d (com.mybiz.mygame:id/fragment_container) for fragment MainMenuFragment{4052d780 #0 id=0x7f05000d}안드로이드 조각 오류 : ID

확인이 응용 프로그램은 설정 방법 :

두 바르가 생성됩니다

: 다음

private static View oGoogleGamesView ; 
private static RelativeLayout oViewGroup ; 

에서 에서 onCreate :

oViewGroup = new RelativeLayout (this) ; 
setContentView (oViewGroup) ; 

LayoutInflater inflater = (LayoutInflater)this.getSystemService (Context.LAYOUT_INFLATER_SERVICE) ;  
oGoogleGamesView  = inflater.inflate (R.layout.ggmain, oViewGroup, false) ; 

그리고 나는 단편을 게재하도록 노력 :

// create fragments 
mMainMenuFragment = new MainMenuFragment(); 

// listen to fragment events 
mMainMenuFragment.setListener(this); 

// add initial fragment (welcome fragment) 
getSupportFragmentManager().beginTransaction().add(R.id.fragment_container, 
     mMainMenuFragment).commit(); 

그리고 여기에는 오류가 발생하여 충돌합니다. 다음은 XML 파일은 다음과 같습니다

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/fragment_container" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" > 
</FrameLayout> 

내가 사고없이 조각을 보여주기 위해 무엇을 할 수 있는가?

답변

1

당신은 oViewGroup에 앱보기를 설정 :

setContentView (oViewGroup) ; 

그런 다음 다른보기를 팽창하고 매달려두고 :

oGoogleGamesView  = inflater.inflate (R.layout.ggmain, oViewGroup, false) ; 

실제로 가지고 oGoogleGamesView 앱에서 레이아웃, 당신은에 있습니다 현재보기에 추가하면 그 안에 포함 된 ID를 참조 할 수 있습니다.

oViewGroup.addView(oGoogleGamesView, LayoutParams); 
1

시도해보십시오. onCreate 메서드로 setContentView (R.layout.yourLayout); 여기서 yourLayout은 질문에 넣은 frameLayout이 포함 된 xml 파일입니다.

+0

감사합니다. 전자 회신하지만,이 일을 내 애플 리케이션을 중단됩니다, 내 ContentView를 oViewGroup로 설정해야합니다. – Selzier

+0

MainMenuFragment 코드를 게시 할 수 있습니까? –