2017-04-16 25 views
1

1- ImageViewのを追加するときに、私は2のEditTextと1つのボタンがある断片を有する(コードを下回っている)アンドロイドスタジオエラー断片に

<android.support.constraint.ConstraintLayout                      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="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.junior_yao.fragmentfrombeginning.Top_Fragment" 
    tools:layout_editor_absoluteY="81dp" 
    tools:layout_editor_absoluteX="0dp"> 

    <EditText 
    android:id="@+id/editText1" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:ems="10" 
    android:hint="information" 
    android:inputType="text|textShortMessage" 
    android:layout_marginRight="8dp" 
    app:layout_constraintRight_toRightOf="parent" 
    android:layout_marginLeft="8dp" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintTop_toTopOf="parent" 
    android:layout_marginTop="16dp" 
    app:layout_constraintHorizontal_bias="0.503" /> 

    <EditText 
    android:id="@+id/editText2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:ems="10" 
    android:hint="information" 
    android:inputType="textPersonName" 
    android:layout_marginRight="8dp" 
    app:layout_constraintRight_toRightOf="@+id/editText1" 
    android:layout_marginLeft="0dp" 
    app:layout_constraintLeft_toLeftOf="@+id/editText1" 
    android:layout_marginTop="23dp" 
    app:layout_constraintTop_toBottomOf="@+id/editText1" 
    app:layout_constraintHorizontal_bias="0.0" /> 

    <Button 
    android:id="@+id/button" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Send Info" 
    android:layout_marginRight="8dp" 
    app:layout_constraintRight_toRightOf="@+id/editText1" 
    android:layout_marginLeft="8dp" 
    app:layout_constraintLeft_toLeftOf="@+id/editText1" 
    android:layout_marginTop="32dp" 
    app:layout_constraintTop_toBottomOf="@+id/editText2" 
    app:layout_constraintHorizontal_bias="0.495" /> 

</android.support.constraint.ConstraintLayout> 

2-私は一つの画像表示と2を持っている別の断片を有しますTextViewの第3部では

<android.support.constraint.ConstraintLayout   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="match_parent" 
    android:layout_height="match_parent" 
    tools:context="com.example.junior_yao.fragmentfrombeginning.Down_Fragment" 
> 

    <ImageView 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:src="@drawable/androidtest" 
    tools:layout_constraintTop_creator="1" 
    tools:layout_constraintLeft_creator="1" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintTop_toTopOf="parent" 
    android:layout_marginLeft="0dp" 
    android:layout_marginTop="0dp" 
    android:id="@+id/imageView" /> 

    <TextView 
    android:id="@+id/textView2" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Text2" 
    android:textSize="25dp" 
    android:textColor="#7FFF00" 
    tools:layout_constraintRight_creator="1" 
    tools:layout_constraintBottom_creator="1" 
    app:layout_constraintBottom_toBottomOf="parent" 
    app:layout_constraintRight_toRightOf="parent" 
    tools:layout_constraintLeft_creator="1" 
    android:layout_marginBottom="30dp" 
    app:layout_constraintLeft_toLeftOf="parent" /> 

    <TextView 
    android:id="@+id/textView3" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:text="Text1" 
    android:textSize="25dp" 
    android:textColor="#7FFF00" 
    android:layout_marginRight="8dp" 
    app:layout_constraintRight_toRightOf="parent" 
    android:layout_marginLeft="8dp" 
    app:layout_constraintLeft_toLeftOf="parent" 
    app:layout_constraintTop_toTopOf="parent" 
    android:layout_marginTop="44dp" /> 
</android.support.constraint.ConstraintLayout> 

私がメインの活動のレイアウト
3に、これらの2フラグメントを追加 - 私は最初のフラグメントを追加する場合(私はエラーを得ていない)

4 - ここで問題

私はアプリが起動しない第二のフラグメントを追加した場合、私はあなたが助けることができるので、より多くの情報を追加する必要が

 <?xml version="1.0" encoding="utf-8"?> 
    <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="match_parent" 
     android:layout_height="match_parent" 
    tools:context="com.example.junior_yao.fragmentfrombeginning.MainActivity"> 

    <fragment 
    android:id="@+id/fragment" 
     android:name="com.example.junior_yao.fragmentfrombeginning.Top_Fragment" 
     android:layout_width="match_parent" 
     android:layout_height="250dp" 
    android:layout_alignParentTop="true" 
    android:layout_alignParentStart="true" 
    /> 

    <fragment 
    android:id="@+id/fragment12" 
     android:name="com.example.junior_yao.fragmentfrombeginning.Down_Fragment" 
     android:layout_width="match_parent" 
     android:layout_height="250dp" 
     android:layout_alignParentBottom="true" 
     android:layout_alignParentStart="true" 

     /> 


    </RelativeLayout> 

答えて

0

をそれを把握するために助けてください、ジャワ破片が呼び出されて作成されているコードと問題を解決するのに役立つlogcatも、XML設計コードは役に立ちません。

+0

のJavaコード大丈夫申し訳ありません1番目の断片のjavaです –

0

ここで第一のフラグメントのためのJavaコード

 package com.example.junior_yao.fragmentfrombeginning; 


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


     public class Top_Fragment extends Fragment { 



     public Top_Fragment() { 
     } 


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

     return inflater.inflate(R.layout.fragment_top, container, false); 
} 

     @Override 
     public void onActivityCreated(@Nullable Bundle savedInstanceState) { 
     super.onActivityCreated(savedInstanceState); 
      } 
     } 

今第二の断片

  package com.example.junior_yao.fragmentfrombeginning; 


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

      public class Down_Fragment extends Fragment { 


      public Down_Fragment() { 

        } 


       @Override 
      public View onCreateView(LayoutInflater inflater, ViewGroup container, 
         Bundle savedInstanceState) { 
        // Inflate the layout for this fragment 
       return inflater.inflate(R.layout.fragment_down, container, false); 
} 

       @Override 
        public void onActivityCreated(@Nullable Bundle savedInstanceState) { 
       super.onActivityCreated(savedInstanceState); 
      } 
      } 

のJavaコードここでの主な活動

 package com.example.junior_yao.fragmentfrombeginning; 

     import android.support.v7.app.AppCompatActivity; 
     import android.os.Bundle; 

     public class MainActivity extends AppCompatActivity { 

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