2013-07-28 7 views
0

Android에서 간단한 조각 코드를 실행하는 중에 오류가 발생했습니다. 심지어클래스 조각을 부 풀리는 중 오류가 발생했습니다 - 간단한 조각 코드가 작동하지 않습니다.

오류 팽창 클래스 단편의 레이아웃을 표시하고 (선형 레이아웃) 이진 XML 파일 라인 (상대 레이아웃) # 7, # 8로서 로그 캣에서 예외를 출력하지 않는다. 여기

내 코드입니다 :

fragment1.xml

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

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:text="Heyy Thats Fragment 1" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 

</RelativeLayout> 

fragement1.java

package com.example.app1; 

import android.os.Bundle; 
import android.support.v4.app.Fragment; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 

public class Fragment1 extends Fragment { 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
     Bundle savedInstanceState) { 

      View view = inflater.inflate(R.layout.fragment1, container, false); 
      return view; 
    } 
} 

fragment2.xml

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

    <TextView 
     android:id="@+id/textView1" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerHorizontal="true" 
     android:layout_centerVertical="true" 
     android:text="Heyy Thats Fragment 2" 
     android:textAppearance="?android:attr/textAppearanceLarge" /> 
</RelativeLayout> 

Fragment2.java

package com.example.app1; 

import android.os.Bundle; 
import android.support.v4.app.Fragment; 
import android.view.LayoutInflater; 
import android.view.View; 
import android.view.ViewGroup; 

public class Fragment2 extends Fragment { 

    @Override 
    public View onCreateView(LayoutInflater inflater, ViewGroup container, 
      Bundle savedInstanceState) { 
       View view = inflater.inflate(R.layout.fragment2, 
       container, false); 

       return view; 
    } 
} 

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    tools:context=".FragmentExampleActivity" > 

    <fragment 
     android:id="@+id/toolbar_fragment" 
     android:name="com.example.app1.Fragment1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentTop="true" 
     tools:layout="@layout/fragment1" 
     class="com.example.app1.Fragment"/> 

    <fragment 
     android:id="@+id/text_fragment" 
     android:name="com.example.app1.Fragment2" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_alignParentLeft="true" 
     android:layout_centerVertical="true" 
     tools:layout="@layout/fragment2" 
     class="com.example.app1.Fragment2"/> 

</RelativeLayout> 

MainActivity.java

package com.example.app1; 

import android.os.Bundle; 
import android.support.v4.app.FragmentActivity; 
import android.view.Menu; 

public class MainActivity extends FragmentActivity { 

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

    @Override 
    public boolean onCreateOptionsMenu(Menu menu) { 
     // Inflate the menu; this adds items to the action bar if it is present. 
     getMenuInflater().inflate(R.menu.activity_main, menu); 
     return true; 
    } 
} 

및 매니페스트 3 개 활동을 포함! Fragment1, Fragment2 및 MainActivity.

답변

1

class="com.example.app1.Fragment" with class="com.example.app1.Fragment1" 

"1"이 친구를 해결

+0

놓친 대체 activity_main.xml

15에서의 라인을 볼? –

+0

yah 그것은 일했다. .. 감사하는 많은 형제. .. 그것은 사람이 할 수있는 어리석은 어리석은 실수이었다! 고마워요 :) – Zest

관련 문제