2012-11-12 2 views
0

저는 FragmentsAndroid에두고 있습니다. LayoutInflater없이 프로그래밍 방식으로 내보기를 부 풀리고 싶습니다. 이에서 onCreate 방법 내 FragmentActivity에 그러나레이아웃 인플레이 터없이 조각보기를 만드는 방법은 무엇입니까?

@Override 
public View onCreateView (LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) 
{ 
    return new View(inflater.getContext()); 
} 

: 내 class에서 어떤 extends Fragment,이 같은 기본적인 일을 수행하고자하는

@Override 
public void onCreate(Bundle savedInstanceState) 
{ 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); 
} 

main.xml :

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:orientation="vertical" > 

    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:text="@string/hello" /> 

    <fragment class="edu.self.myFragment" 
     android:id="@+id/titles" 
     android:tag="foo" 
     android:layout_width="50px" 
     android:layout_height="50px" /> 

</LinearLayout> 

레이아웃에 오류가 발생했습니다.

11-11 23:25:18.142: E/AndroidRuntime(1162): Caused by: java.lang.IllegalArgumentException: Binary XML file line #12: Duplicate id 0x7f050000, tag foo, or parent id 0x0 with another fragment for edu.self.myFragment 

이 오류를 해결하려면 무엇을해야합니까?

+0

@Raghunandan. 깨진 링크 –

+0

@Binghammer 개조가 질문을 삭제했습니다. 따라서 깨진 링크 – Raghunandan

답변

-1

조각을 포함하는 XML을 다른 조각 안에 팽창시킬 수 없습니다. 수동으로 하위 조각을 추가해야합니다.

관련 문제