2014-02-09 1 views
0

문자 그대로 가장 기본적인 앱이 진행 중입니다. 새로운 레이아웃을위한 XML 파일을 새로 만들었습니다. 몇 가지를 추가했습니다. MainActivity에서 setContentView()을 변경하여 문제가 발생했습니다. 여기까지 내 코드가 있습니다.Android 멍청한 놈, 레이아웃이 작동하지 않습니다.

내에서 onCreate() :

@Override 
protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
    setContentView(R.layout.new_layout); 

    if (savedInstanceState == null) { 
     getSupportFragmentManager().beginTransaction() 
       .add(R.id.container, new PlaceholderFragment()) 
       .commit(); 
    } 
} 

내 XML의 new_layout : 그냥 실행에 도착하려고

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

    <TextView 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="New Text" 
     android:id="@+id/textView" /> 

    <EditText 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:id="@+id/editText" 
     android:layout_weight="1" 
     android:inputType="text" /> 

    <Button 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:text="New Button" 
     android:id="@+id/button" /> 
</LinearLayout> 

합법.

오류 :

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.androidsdk.demo/com.example.androidsdk.demo.MainActivity}: java.lang.IllegalArgumentException: No view found for id 0x7f07003c (com.example.androidsdk.demo:id/container) for fragment PlaceholderFragment{4267dc90 #0 id=0x7f07003c} 

편집 :

enter image description here

감사합니다 :) 당신이 당신의 조각에 대한 자리 표시를 해달라고처럼

답변

0

보인다. 조각을 렌더링하기 위해 뷰에 배치해야합니다.

관련 문제