“no view found for id for fragment” error before onCreateView() called











up vote
1
down vote

favorite
1












This is related to several posts, but I don't see anything that explains the order of view creation in the view hierarchy (static - xml and dynamic - in code).



I have a FragmentActivity hosting an Activity and a Fragment. I'm getting a runtime error from a view not being created for the fragment before the fragment's onCreateView is called. It's difficult to determine what the calling method is that can't find the view as the debugger can't seem to find the right line-numbers during step-through.



I can't get the source to attach correctly to see inside FragmentManager as there seems to be a mismatch between the dl'd source and .jar



I placed a Log.i entry in StreamingActivity.onCreateView and the error occurs before that.



Here is the relevant LogCat:



07-19 10:13:36.091: I/StreamingActivity(9886): onCreate
07-19 10:13:42.271: W/dalvikvm(9886): threadid=1: thread exiting with uncaught exception (group=0x40020560)
07-19 10:13:42.281: E/AndroidRuntime(9886): FATAL EXCEPTION: main
07-19 10:13:42.281: E/AndroidRuntime(9886): java.lang.RuntimeException: Unable to start activity
ComponentInfo{kesten.fragmentstestbed/kesten.fragmentstestbed.FragmentsMainActivity}:
java.lang.IllegalArgumentException: No view found for id 0x7f05002e for fragment
StreamingActivity{4052f810 #0 id=0x7f05002e}
caused by
java.lang.IllegalArgumentException: No view found for id 0x7f05002e for fragment
StreamingActivity{40530948 #0 id=0x7f05002e}
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:865)


my java file snippets:



public class FragmentsMainActivity extends FragmentActivity {

public final static int STARTUP_ACTIVITY_RESULT=0;

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

if(savedInstanceState == null) {
Intent intentStartupActivity = new Intent(this, StartupActivity.class);
if(intentStartupActivity != null)
startActivityForResult(intentStartupActivity, STARTUP_ACTIVITY_RESULT);

// get an instance of FragmentTransaction from your Activity
FragmentTransaction fragmentTransaction =
getSupportFragmentManager().beginTransaction();

//add a fragment
StreamingActivity streamingActivity = new StreamingActivity();
if (streamingActivity != null) {
fragmentTransaction.add(R.id.streamingactivity, streamingActivity);
fragmentTransaction.commit();
}
}
}


my Fragment:



public class StreamingActivity extends Fragment {

public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Log.i("StreamingActivity","onCreate")
}


my layout files:
"res/layout/main.xml"



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

<FrameLayout
android:id="@+id/streamingactivity"
android:layout_width="0px"
android:layout_height="match_parent">
</FrameLayout>


<!-- IMU -->
<TextView
android:id="@+id/imu_label"
style="@style/Label.Title"
android:text="@string/imu"
/>

<kesten.fragmentstestbed.ImuView
android:id="@+id/imu_values"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imu_label"
android:text=""
/>

<!-- Accelerometer -->
<TextView
android:id="@+id/accelerometer_label"
style="@style/Label.Title"
android:text="@string/accelerometer"
android:layout_below="@+id/imu_values"
/>

<!-- Filtered -->
<kesten.fragmentstestbed.CoordinateView
android:id="@+id/accelerometer_filtered_coordinates"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/accelerometer_label"
android:text="@string/filtered"
/>

</RelativeLayout>


and "activity_fragments_main.xml" for my FragmentActivity



<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" >

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:padding="@dimen/padding_medium"
android:text="@string/hello_world"
tools:context=".FragmentsMainActivity" />

</RelativeLayout>


Possible causes of id not found error gleaned from other Stackoverflow threads:




  • wrong layout in setContentView() of the onCreate() method of the FragmentActivity.


I checked and my xml files are all there. Maybe there's a syntax error or missing linked resource, but i can't see it. I understand the HierarchyViewer would be a useful tool to debug the UI, but i can't get it working.




  • the id passed into FragmentTransaction.add must be a child of the layout specified in setContentView.


my FragmentActivity's onCreate
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_fragments_main);



my Fragment's onCreateView



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

Log.i("StreamingActivity","onCreateView");
View view = inflater.inflate(R.layout.main, container, false);


I presume that the LayoutManager passes the correct value for container, i.e., the one set in FragmentActivity's setContentView(). But we never make it there anyway. The error in the logCat occurs before we enter onCreateView().



The only thing i can think of atm is that the startupActivity (which is closed third party) called after setContentView and before StreamingActivity sets the content view to something besides R.layout.activity_fragments_main which is not a parent of my fragment's view.



The problem seems to stem from the fact that while Activity has setContentView which can be called whenever, Fragment only has onCreateView() which gets called after fragment transactions that start the fragment.



Why and what is trying to access the fragment's view before onCreateView() is called?



darKoram










share|improve this question


























    up vote
    1
    down vote

    favorite
    1












    This is related to several posts, but I don't see anything that explains the order of view creation in the view hierarchy (static - xml and dynamic - in code).



    I have a FragmentActivity hosting an Activity and a Fragment. I'm getting a runtime error from a view not being created for the fragment before the fragment's onCreateView is called. It's difficult to determine what the calling method is that can't find the view as the debugger can't seem to find the right line-numbers during step-through.



    I can't get the source to attach correctly to see inside FragmentManager as there seems to be a mismatch between the dl'd source and .jar



    I placed a Log.i entry in StreamingActivity.onCreateView and the error occurs before that.



    Here is the relevant LogCat:



    07-19 10:13:36.091: I/StreamingActivity(9886): onCreate
    07-19 10:13:42.271: W/dalvikvm(9886): threadid=1: thread exiting with uncaught exception (group=0x40020560)
    07-19 10:13:42.281: E/AndroidRuntime(9886): FATAL EXCEPTION: main
    07-19 10:13:42.281: E/AndroidRuntime(9886): java.lang.RuntimeException: Unable to start activity
    ComponentInfo{kesten.fragmentstestbed/kesten.fragmentstestbed.FragmentsMainActivity}:
    java.lang.IllegalArgumentException: No view found for id 0x7f05002e for fragment
    StreamingActivity{4052f810 #0 id=0x7f05002e}
    caused by
    java.lang.IllegalArgumentException: No view found for id 0x7f05002e for fragment
    StreamingActivity{40530948 #0 id=0x7f05002e}
    at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:865)


    my java file snippets:



    public class FragmentsMainActivity extends FragmentActivity {

    public final static int STARTUP_ACTIVITY_RESULT=0;

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

    if(savedInstanceState == null) {
    Intent intentStartupActivity = new Intent(this, StartupActivity.class);
    if(intentStartupActivity != null)
    startActivityForResult(intentStartupActivity, STARTUP_ACTIVITY_RESULT);

    // get an instance of FragmentTransaction from your Activity
    FragmentTransaction fragmentTransaction =
    getSupportFragmentManager().beginTransaction();

    //add a fragment
    StreamingActivity streamingActivity = new StreamingActivity();
    if (streamingActivity != null) {
    fragmentTransaction.add(R.id.streamingactivity, streamingActivity);
    fragmentTransaction.commit();
    }
    }
    }


    my Fragment:



    public class StreamingActivity extends Fragment {

    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Log.i("StreamingActivity","onCreate")
    }


    my layout files:
    "res/layout/main.xml"



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

    <FrameLayout
    android:id="@+id/streamingactivity"
    android:layout_width="0px"
    android:layout_height="match_parent">
    </FrameLayout>


    <!-- IMU -->
    <TextView
    android:id="@+id/imu_label"
    style="@style/Label.Title"
    android:text="@string/imu"
    />

    <kesten.fragmentstestbed.ImuView
    android:id="@+id/imu_values"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/imu_label"
    android:text=""
    />

    <!-- Accelerometer -->
    <TextView
    android:id="@+id/accelerometer_label"
    style="@style/Label.Title"
    android:text="@string/accelerometer"
    android:layout_below="@+id/imu_values"
    />

    <!-- Filtered -->
    <kesten.fragmentstestbed.CoordinateView
    android:id="@+id/accelerometer_filtered_coordinates"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_below="@+id/accelerometer_label"
    android:text="@string/filtered"
    />

    </RelativeLayout>


    and "activity_fragments_main.xml" for my FragmentActivity



    <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" >

    <TextView
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_centerHorizontal="true"
    android:layout_centerVertical="true"
    android:padding="@dimen/padding_medium"
    android:text="@string/hello_world"
    tools:context=".FragmentsMainActivity" />

    </RelativeLayout>


    Possible causes of id not found error gleaned from other Stackoverflow threads:




    • wrong layout in setContentView() of the onCreate() method of the FragmentActivity.


    I checked and my xml files are all there. Maybe there's a syntax error or missing linked resource, but i can't see it. I understand the HierarchyViewer would be a useful tool to debug the UI, but i can't get it working.




    • the id passed into FragmentTransaction.add must be a child of the layout specified in setContentView.


    my FragmentActivity's onCreate
    @Override
    public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_fragments_main);



    my Fragment's onCreateView



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

    Log.i("StreamingActivity","onCreateView");
    View view = inflater.inflate(R.layout.main, container, false);


    I presume that the LayoutManager passes the correct value for container, i.e., the one set in FragmentActivity's setContentView(). But we never make it there anyway. The error in the logCat occurs before we enter onCreateView().



    The only thing i can think of atm is that the startupActivity (which is closed third party) called after setContentView and before StreamingActivity sets the content view to something besides R.layout.activity_fragments_main which is not a parent of my fragment's view.



    The problem seems to stem from the fact that while Activity has setContentView which can be called whenever, Fragment only has onCreateView() which gets called after fragment transactions that start the fragment.



    Why and what is trying to access the fragment's view before onCreateView() is called?



    darKoram










    share|improve this question
























      up vote
      1
      down vote

      favorite
      1









      up vote
      1
      down vote

      favorite
      1






      1





      This is related to several posts, but I don't see anything that explains the order of view creation in the view hierarchy (static - xml and dynamic - in code).



      I have a FragmentActivity hosting an Activity and a Fragment. I'm getting a runtime error from a view not being created for the fragment before the fragment's onCreateView is called. It's difficult to determine what the calling method is that can't find the view as the debugger can't seem to find the right line-numbers during step-through.



      I can't get the source to attach correctly to see inside FragmentManager as there seems to be a mismatch between the dl'd source and .jar



      I placed a Log.i entry in StreamingActivity.onCreateView and the error occurs before that.



      Here is the relevant LogCat:



      07-19 10:13:36.091: I/StreamingActivity(9886): onCreate
      07-19 10:13:42.271: W/dalvikvm(9886): threadid=1: thread exiting with uncaught exception (group=0x40020560)
      07-19 10:13:42.281: E/AndroidRuntime(9886): FATAL EXCEPTION: main
      07-19 10:13:42.281: E/AndroidRuntime(9886): java.lang.RuntimeException: Unable to start activity
      ComponentInfo{kesten.fragmentstestbed/kesten.fragmentstestbed.FragmentsMainActivity}:
      java.lang.IllegalArgumentException: No view found for id 0x7f05002e for fragment
      StreamingActivity{4052f810 #0 id=0x7f05002e}
      caused by
      java.lang.IllegalArgumentException: No view found for id 0x7f05002e for fragment
      StreamingActivity{40530948 #0 id=0x7f05002e}
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:865)


      my java file snippets:



      public class FragmentsMainActivity extends FragmentActivity {

      public final static int STARTUP_ACTIVITY_RESULT=0;

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

      if(savedInstanceState == null) {
      Intent intentStartupActivity = new Intent(this, StartupActivity.class);
      if(intentStartupActivity != null)
      startActivityForResult(intentStartupActivity, STARTUP_ACTIVITY_RESULT);

      // get an instance of FragmentTransaction from your Activity
      FragmentTransaction fragmentTransaction =
      getSupportFragmentManager().beginTransaction();

      //add a fragment
      StreamingActivity streamingActivity = new StreamingActivity();
      if (streamingActivity != null) {
      fragmentTransaction.add(R.id.streamingactivity, streamingActivity);
      fragmentTransaction.commit();
      }
      }
      }


      my Fragment:



      public class StreamingActivity extends Fragment {

      public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      Log.i("StreamingActivity","onCreate")
      }


      my layout files:
      "res/layout/main.xml"



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

      <FrameLayout
      android:id="@+id/streamingactivity"
      android:layout_width="0px"
      android:layout_height="match_parent">
      </FrameLayout>


      <!-- IMU -->
      <TextView
      android:id="@+id/imu_label"
      style="@style/Label.Title"
      android:text="@string/imu"
      />

      <kesten.fragmentstestbed.ImuView
      android:id="@+id/imu_values"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/imu_label"
      android:text=""
      />

      <!-- Accelerometer -->
      <TextView
      android:id="@+id/accelerometer_label"
      style="@style/Label.Title"
      android:text="@string/accelerometer"
      android:layout_below="@+id/imu_values"
      />

      <!-- Filtered -->
      <kesten.fragmentstestbed.CoordinateView
      android:id="@+id/accelerometer_filtered_coordinates"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/accelerometer_label"
      android:text="@string/filtered"
      />

      </RelativeLayout>


      and "activity_fragments_main.xml" for my FragmentActivity



      <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" >

      <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:padding="@dimen/padding_medium"
      android:text="@string/hello_world"
      tools:context=".FragmentsMainActivity" />

      </RelativeLayout>


      Possible causes of id not found error gleaned from other Stackoverflow threads:




      • wrong layout in setContentView() of the onCreate() method of the FragmentActivity.


      I checked and my xml files are all there. Maybe there's a syntax error or missing linked resource, but i can't see it. I understand the HierarchyViewer would be a useful tool to debug the UI, but i can't get it working.




      • the id passed into FragmentTransaction.add must be a child of the layout specified in setContentView.


      my FragmentActivity's onCreate
      @Override
      public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_fragments_main);



      my Fragment's onCreateView



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

      Log.i("StreamingActivity","onCreateView");
      View view = inflater.inflate(R.layout.main, container, false);


      I presume that the LayoutManager passes the correct value for container, i.e., the one set in FragmentActivity's setContentView(). But we never make it there anyway. The error in the logCat occurs before we enter onCreateView().



      The only thing i can think of atm is that the startupActivity (which is closed third party) called after setContentView and before StreamingActivity sets the content view to something besides R.layout.activity_fragments_main which is not a parent of my fragment's view.



      The problem seems to stem from the fact that while Activity has setContentView which can be called whenever, Fragment only has onCreateView() which gets called after fragment transactions that start the fragment.



      Why and what is trying to access the fragment's view before onCreateView() is called?



      darKoram










      share|improve this question













      This is related to several posts, but I don't see anything that explains the order of view creation in the view hierarchy (static - xml and dynamic - in code).



      I have a FragmentActivity hosting an Activity and a Fragment. I'm getting a runtime error from a view not being created for the fragment before the fragment's onCreateView is called. It's difficult to determine what the calling method is that can't find the view as the debugger can't seem to find the right line-numbers during step-through.



      I can't get the source to attach correctly to see inside FragmentManager as there seems to be a mismatch between the dl'd source and .jar



      I placed a Log.i entry in StreamingActivity.onCreateView and the error occurs before that.



      Here is the relevant LogCat:



      07-19 10:13:36.091: I/StreamingActivity(9886): onCreate
      07-19 10:13:42.271: W/dalvikvm(9886): threadid=1: thread exiting with uncaught exception (group=0x40020560)
      07-19 10:13:42.281: E/AndroidRuntime(9886): FATAL EXCEPTION: main
      07-19 10:13:42.281: E/AndroidRuntime(9886): java.lang.RuntimeException: Unable to start activity
      ComponentInfo{kesten.fragmentstestbed/kesten.fragmentstestbed.FragmentsMainActivity}:
      java.lang.IllegalArgumentException: No view found for id 0x7f05002e for fragment
      StreamingActivity{4052f810 #0 id=0x7f05002e}
      caused by
      java.lang.IllegalArgumentException: No view found for id 0x7f05002e for fragment
      StreamingActivity{40530948 #0 id=0x7f05002e}
      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:865)


      my java file snippets:



      public class FragmentsMainActivity extends FragmentActivity {

      public final static int STARTUP_ACTIVITY_RESULT=0;

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

      if(savedInstanceState == null) {
      Intent intentStartupActivity = new Intent(this, StartupActivity.class);
      if(intentStartupActivity != null)
      startActivityForResult(intentStartupActivity, STARTUP_ACTIVITY_RESULT);

      // get an instance of FragmentTransaction from your Activity
      FragmentTransaction fragmentTransaction =
      getSupportFragmentManager().beginTransaction();

      //add a fragment
      StreamingActivity streamingActivity = new StreamingActivity();
      if (streamingActivity != null) {
      fragmentTransaction.add(R.id.streamingactivity, streamingActivity);
      fragmentTransaction.commit();
      }
      }
      }


      my Fragment:



      public class StreamingActivity extends Fragment {

      public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      Log.i("StreamingActivity","onCreate")
      }


      my layout files:
      "res/layout/main.xml"



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

      <FrameLayout
      android:id="@+id/streamingactivity"
      android:layout_width="0px"
      android:layout_height="match_parent">
      </FrameLayout>


      <!-- IMU -->
      <TextView
      android:id="@+id/imu_label"
      style="@style/Label.Title"
      android:text="@string/imu"
      />

      <kesten.fragmentstestbed.ImuView
      android:id="@+id/imu_values"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/imu_label"
      android:text=""
      />

      <!-- Accelerometer -->
      <TextView
      android:id="@+id/accelerometer_label"
      style="@style/Label.Title"
      android:text="@string/accelerometer"
      android:layout_below="@+id/imu_values"
      />

      <!-- Filtered -->
      <kesten.fragmentstestbed.CoordinateView
      android:id="@+id/accelerometer_filtered_coordinates"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/accelerometer_label"
      android:text="@string/filtered"
      />

      </RelativeLayout>


      and "activity_fragments_main.xml" for my FragmentActivity



      <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" >

      <TextView
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_centerHorizontal="true"
      android:layout_centerVertical="true"
      android:padding="@dimen/padding_medium"
      android:text="@string/hello_world"
      tools:context=".FragmentsMainActivity" />

      </RelativeLayout>


      Possible causes of id not found error gleaned from other Stackoverflow threads:




      • wrong layout in setContentView() of the onCreate() method of the FragmentActivity.


      I checked and my xml files are all there. Maybe there's a syntax error or missing linked resource, but i can't see it. I understand the HierarchyViewer would be a useful tool to debug the UI, but i can't get it working.




      • the id passed into FragmentTransaction.add must be a child of the layout specified in setContentView.


      my FragmentActivity's onCreate
      @Override
      public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_fragments_main);



      my Fragment's onCreateView



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

      Log.i("StreamingActivity","onCreateView");
      View view = inflater.inflate(R.layout.main, container, false);


      I presume that the LayoutManager passes the correct value for container, i.e., the one set in FragmentActivity's setContentView(). But we never make it there anyway. The error in the logCat occurs before we enter onCreateView().



      The only thing i can think of atm is that the startupActivity (which is closed third party) called after setContentView and before StreamingActivity sets the content view to something besides R.layout.activity_fragments_main which is not a parent of my fragment's view.



      The problem seems to stem from the fact that while Activity has setContentView which can be called whenever, Fragment only has onCreateView() which gets called after fragment transactions that start the fragment.



      Why and what is trying to access the fragment's view before onCreateView() is called?



      darKoram







      android view fragment illegalargumentexception android-fragmentactivity






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jul 20 '12 at 23:34









      darKoram

      71811024




      71811024
























          3 Answers
          3






          active

          oldest

          votes

















          up vote
          0
          down vote













          The TextView in activty_fragments_main has no id. I ran into a similar error, and added an id, and all of a sudden things started working...






          share|improve this answer




























            up vote
            0
            down vote













            the following FrameLayout should be in activty_fragments_main



               <FrameLayout
            android:id="@+id/streamingactivity"
            android:layout_width="0px"
            android:layout_height="match_parent">
            </FrameLayout>


            the below function adds a fragment inside the layout provided in the first aurgument:



             fragmentTransaction.add(R.id.streamingactivity, streamingActivity);


            So try changing:



            <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" >

            <TextView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_centerVertical="true"
            android:padding="@dimen/padding_medium"
            android:text="@string/hello_world"
            tools:context=".FragmentsMainActivity" />

            </RelativeLayout>


            to:



            <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" >


            <FrameLayout
            android:id="@+id/streamingactivity"
            android:layout_width="match_parent"
            android:layout_height="match_parent">
            </FrameLayout>

            </RelativeLayout>





            share|improve this answer




























              up vote
              0
              down vote














              In FragmentMainActivity you are adding fragment to to id streamingactivity




              fragmentTransaction.add(R.id.streamingactivity, streamingActivity);



              and "activity_fragments_main.xml" for my FragmentMainActivity




              <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" >

              <TextView
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_centerHorizontal="true"
              android:layout_centerVertical="true"
              android:padding="@dimen/padding_medium"
              android:text="@string/hello_world"
              tools:context=".FragmentsMainActivity" />

              </RelativeLayout>


              //your layout must contains a FrameLayout with id streamingactivity .you Activity must contains



              <FrameLayout 
              android:id="@+id/streamingactivity"
              ....
              ..>



              And your StreamingActivity which is a Fragment must import android.support.v4.Fragment. And must implement onCreateView




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


              Or One more problem may be . Your have interchanged the LayoutId of Fragment and Activity. As your names look like






              share|improve this answer





















                Your Answer






                StackExchange.ifUsing("editor", function () {
                StackExchange.using("externalEditor", function () {
                StackExchange.using("snippets", function () {
                StackExchange.snippets.init();
                });
                });
                }, "code-snippets");

                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "1"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f11588209%2fno-view-found-for-id-for-fragment-error-before-oncreateview-called%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                0
                down vote













                The TextView in activty_fragments_main has no id. I ran into a similar error, and added an id, and all of a sudden things started working...






                share|improve this answer

























                  up vote
                  0
                  down vote













                  The TextView in activty_fragments_main has no id. I ran into a similar error, and added an id, and all of a sudden things started working...






                  share|improve this answer























                    up vote
                    0
                    down vote










                    up vote
                    0
                    down vote









                    The TextView in activty_fragments_main has no id. I ran into a similar error, and added an id, and all of a sudden things started working...






                    share|improve this answer












                    The TextView in activty_fragments_main has no id. I ran into a similar error, and added an id, and all of a sudden things started working...







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Aug 7 '12 at 5:47









                    Ben Lerner

                    1644




                    1644
























                        up vote
                        0
                        down vote













                        the following FrameLayout should be in activty_fragments_main



                           <FrameLayout
                        android:id="@+id/streamingactivity"
                        android:layout_width="0px"
                        android:layout_height="match_parent">
                        </FrameLayout>


                        the below function adds a fragment inside the layout provided in the first aurgument:



                         fragmentTransaction.add(R.id.streamingactivity, streamingActivity);


                        So try changing:



                        <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" >

                        <TextView
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:layout_centerHorizontal="true"
                        android:layout_centerVertical="true"
                        android:padding="@dimen/padding_medium"
                        android:text="@string/hello_world"
                        tools:context=".FragmentsMainActivity" />

                        </RelativeLayout>


                        to:



                        <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" >


                        <FrameLayout
                        android:id="@+id/streamingactivity"
                        android:layout_width="match_parent"
                        android:layout_height="match_parent">
                        </FrameLayout>

                        </RelativeLayout>





                        share|improve this answer

























                          up vote
                          0
                          down vote













                          the following FrameLayout should be in activty_fragments_main



                             <FrameLayout
                          android:id="@+id/streamingactivity"
                          android:layout_width="0px"
                          android:layout_height="match_parent">
                          </FrameLayout>


                          the below function adds a fragment inside the layout provided in the first aurgument:



                           fragmentTransaction.add(R.id.streamingactivity, streamingActivity);


                          So try changing:



                          <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" >

                          <TextView
                          android:layout_width="wrap_content"
                          android:layout_height="wrap_content"
                          android:layout_centerHorizontal="true"
                          android:layout_centerVertical="true"
                          android:padding="@dimen/padding_medium"
                          android:text="@string/hello_world"
                          tools:context=".FragmentsMainActivity" />

                          </RelativeLayout>


                          to:



                          <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" >


                          <FrameLayout
                          android:id="@+id/streamingactivity"
                          android:layout_width="match_parent"
                          android:layout_height="match_parent">
                          </FrameLayout>

                          </RelativeLayout>





                          share|improve this answer























                            up vote
                            0
                            down vote










                            up vote
                            0
                            down vote









                            the following FrameLayout should be in activty_fragments_main



                               <FrameLayout
                            android:id="@+id/streamingactivity"
                            android:layout_width="0px"
                            android:layout_height="match_parent">
                            </FrameLayout>


                            the below function adds a fragment inside the layout provided in the first aurgument:



                             fragmentTransaction.add(R.id.streamingactivity, streamingActivity);


                            So try changing:



                            <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" >

                            <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_centerHorizontal="true"
                            android:layout_centerVertical="true"
                            android:padding="@dimen/padding_medium"
                            android:text="@string/hello_world"
                            tools:context=".FragmentsMainActivity" />

                            </RelativeLayout>


                            to:



                            <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" >


                            <FrameLayout
                            android:id="@+id/streamingactivity"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent">
                            </FrameLayout>

                            </RelativeLayout>





                            share|improve this answer












                            the following FrameLayout should be in activty_fragments_main



                               <FrameLayout
                            android:id="@+id/streamingactivity"
                            android:layout_width="0px"
                            android:layout_height="match_parent">
                            </FrameLayout>


                            the below function adds a fragment inside the layout provided in the first aurgument:



                             fragmentTransaction.add(R.id.streamingactivity, streamingActivity);


                            So try changing:



                            <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" >

                            <TextView
                            android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_centerHorizontal="true"
                            android:layout_centerVertical="true"
                            android:padding="@dimen/padding_medium"
                            android:text="@string/hello_world"
                            tools:context=".FragmentsMainActivity" />

                            </RelativeLayout>


                            to:



                            <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" >


                            <FrameLayout
                            android:id="@+id/streamingactivity"
                            android:layout_width="match_parent"
                            android:layout_height="match_parent">
                            </FrameLayout>

                            </RelativeLayout>






                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Feb 27 '14 at 13:08









                            vipul mittal

                            14.6k33039




                            14.6k33039






















                                up vote
                                0
                                down vote














                                In FragmentMainActivity you are adding fragment to to id streamingactivity




                                fragmentTransaction.add(R.id.streamingactivity, streamingActivity);



                                and "activity_fragments_main.xml" for my FragmentMainActivity




                                <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" >

                                <TextView
                                android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_centerHorizontal="true"
                                android:layout_centerVertical="true"
                                android:padding="@dimen/padding_medium"
                                android:text="@string/hello_world"
                                tools:context=".FragmentsMainActivity" />

                                </RelativeLayout>


                                //your layout must contains a FrameLayout with id streamingactivity .you Activity must contains



                                <FrameLayout 
                                android:id="@+id/streamingactivity"
                                ....
                                ..>



                                And your StreamingActivity which is a Fragment must import android.support.v4.Fragment. And must implement onCreateView




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


                                Or One more problem may be . Your have interchanged the LayoutId of Fragment and Activity. As your names look like






                                share|improve this answer

























                                  up vote
                                  0
                                  down vote














                                  In FragmentMainActivity you are adding fragment to to id streamingactivity




                                  fragmentTransaction.add(R.id.streamingactivity, streamingActivity);



                                  and "activity_fragments_main.xml" for my FragmentMainActivity




                                  <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" >

                                  <TextView
                                  android:layout_width="wrap_content"
                                  android:layout_height="wrap_content"
                                  android:layout_centerHorizontal="true"
                                  android:layout_centerVertical="true"
                                  android:padding="@dimen/padding_medium"
                                  android:text="@string/hello_world"
                                  tools:context=".FragmentsMainActivity" />

                                  </RelativeLayout>


                                  //your layout must contains a FrameLayout with id streamingactivity .you Activity must contains



                                  <FrameLayout 
                                  android:id="@+id/streamingactivity"
                                  ....
                                  ..>



                                  And your StreamingActivity which is a Fragment must import android.support.v4.Fragment. And must implement onCreateView




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


                                  Or One more problem may be . Your have interchanged the LayoutId of Fragment and Activity. As your names look like






                                  share|improve this answer























                                    up vote
                                    0
                                    down vote










                                    up vote
                                    0
                                    down vote










                                    In FragmentMainActivity you are adding fragment to to id streamingactivity




                                    fragmentTransaction.add(R.id.streamingactivity, streamingActivity);



                                    and "activity_fragments_main.xml" for my FragmentMainActivity




                                    <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" >

                                    <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_centerHorizontal="true"
                                    android:layout_centerVertical="true"
                                    android:padding="@dimen/padding_medium"
                                    android:text="@string/hello_world"
                                    tools:context=".FragmentsMainActivity" />

                                    </RelativeLayout>


                                    //your layout must contains a FrameLayout with id streamingactivity .you Activity must contains



                                    <FrameLayout 
                                    android:id="@+id/streamingactivity"
                                    ....
                                    ..>



                                    And your StreamingActivity which is a Fragment must import android.support.v4.Fragment. And must implement onCreateView




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


                                    Or One more problem may be . Your have interchanged the LayoutId of Fragment and Activity. As your names look like






                                    share|improve this answer













                                    In FragmentMainActivity you are adding fragment to to id streamingactivity




                                    fragmentTransaction.add(R.id.streamingactivity, streamingActivity);



                                    and "activity_fragments_main.xml" for my FragmentMainActivity




                                    <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" >

                                    <TextView
                                    android:layout_width="wrap_content"
                                    android:layout_height="wrap_content"
                                    android:layout_centerHorizontal="true"
                                    android:layout_centerVertical="true"
                                    android:padding="@dimen/padding_medium"
                                    android:text="@string/hello_world"
                                    tools:context=".FragmentsMainActivity" />

                                    </RelativeLayout>


                                    //your layout must contains a FrameLayout with id streamingactivity .you Activity must contains



                                    <FrameLayout 
                                    android:id="@+id/streamingactivity"
                                    ....
                                    ..>



                                    And your StreamingActivity which is a Fragment must import android.support.v4.Fragment. And must implement onCreateView




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


                                    Or One more problem may be . Your have interchanged the LayoutId of Fragment and Activity. As your names look like







                                    share|improve this answer












                                    share|improve this answer



                                    share|improve this answer










                                    answered Aug 22 '16 at 7:20









                                    Xar E Ahmer

                                    22.4k8151198




                                    22.4k8151198






























                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Stack Overflow!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.





                                        Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                        Please pay close attention to the following guidance:


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f11588209%2fno-view-found-for-id-for-fragment-error-before-oncreateview-called%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        Florida Star v. B. J. F.

                                        Danny Elfman

                                        Lugert, Oklahoma