2016-07-09 10 views
-2

は、私は、このウェブサイトを参照し
私の活動のコードでインフレータのエラーを取得し、私は得ることができないソリューション

私のXMLコード:
がライン#415バイナリXMLファイル:エラー膨張クラスフラグメント

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:orientation="vertical"> 
    <fragment 
    android:id="@+id/projectcommends_combine" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:name="com.servicebellpartner.Fragment.ProjectComments" 
    tools:layout="@layout/project_comments"></fragment></RelativeLayout> 

マイアクティビティコード:

public class OrderDetails extends AppCompatActivity implements View.OnClickListener { 

protected void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 

    setContentView(R.layout.order_detail); 

    FragmentTransaction fragmentTransaction = getFragmentManager().beginTransaction(); 
    ProjectComments projectComments = new ProjectComments(orderid); 
    fragmentTransaction.add(R.id.projectcommends_combine, projectComments); 
    fragmentTransaction.commit(); 
}} 

マイ断片コード:

public class ProjectComments extends Fragment { 
private String orderid; 
public ProjectComments(String orderid){ 
    this.orderid = orderid; 
} 

public void onCreate(Bundle savedInstanceState) { 
    super.onCreate(savedInstanceState); 
} 

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

は私が

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.servicebellpartner/com.servicebellpartner.Activity.OrderDetails}: android.view.InflateException: Binary XML file line #415: Error inflating class fragment 

いずれかが解決策と説明を与えてください実行アプリでエラーの下に取得します。

+0

お願い...スタックトレース全体を共有します... – W0rmH0le

+0

スタックトレースとは何ですか? – vinoth12594

+0

@vinothkumar: 'android.support.v4.app.Fragment'のフラグメントを使用していますか? –

答えて

1

あなたのxmlには相対レイアウトの終了タグがありません。 また、フラグメントにはパブリックなパラメータのないコンストラクタがありません。 したがって、フレームワークによってインスタンス化することはできません。

+0

フラグメントにはパラメータなしコンストラクタはありませんか?コード – vinoth12594

+0

を与えてください。非常に基本的なプログラミングチュートリアルを勉強するのに時間を費やすべきでしょうか?あなたのフラグメントコンストラクタは:public ProjectComments()です。 他:http://stackoverflow.com/questions/25984054/android-fragments-is-empty-constructor-really-required –

関連する問題