Error in code Fragments

Asked

Viewed 52 times

0

Some Solution to: My dear funnel all right when I run 1 simple line of Fragments code from the error below... I already tested... what is strange because I only went from one project to another and changed everything including id content_ini...

01-09 20:11:01.108 4815-4815/com.example.dutra_pc.myapplication E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                  Process: com.example.dutra_pc.myapplication, PID: 4815
                                                                                  java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.dutra_pc.myapplication/com.example.dutra_pc.myapplication.Main2Activity}: java.lang.IllegalArgumentException: No view found for id 0x7f0a0033 (com.example.dutra_pc.myapplication:id/content_ini) for fragment Content_Ini{490f7af #0 id=0x7f0a0033}
                                                                                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
                                                                                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
                                                                                      at android.app.ActivityThread.-wrap11(Unknown Source:0)
                                                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
                                                                                      at android.os.Handler.dispatchMessage(Handler.java:106)
                                                                                      at android.os.Looper.loop(Looper.java:164)
                                                                                      at android.app.ActivityThread.main(ActivityThread.java:6494)
                                                                                      at java.lang.reflect.Method.invoke(Native Method)
                                                                                      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
                                                                                   Caused by: java.lang.IllegalArgumentException: No view found for id 0x7f0a0033 (com.example.dutra_pc.myapplication:id/content_ini) for fragment Content_Ini{490f7af #0 id=0x7f0a0033}
                                                                                      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1413)
                                                                                      at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740)
                                                                                      at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809)
                                                                                      at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799)
                                                                                      at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580)
                                                                                      at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367)
                                                                                      at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322)
                                                                                      at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2229)
                                                                                      at android.support.v4.app.FragmentManagerImpl.dispatchStateChange(FragmentManager.java:3221)
                                                                                      at android.support.v4.app.FragmentManagerImpl.dispatchActivityCreated(FragmentManager.java:3171)
                                                                                      at android.support.v4.app.FragmentController.dispatchActivityCreated(FragmentController.java:192)
                                                                                      at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:560)
                                                                                      at android.support.v7.app.AppCompatActivity.onStart(AppCompatActivity.java:177)
                                                                                      at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1334)
                                                                                      at android.app.Activity.performStart(Activity.java:7019)
                                                                                      at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2741)
                                                                                      at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856) 
                                                                                      at android.app.ActivityThread.-wrap11(Unknown Source:0) 
                                                                                      at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589) 
                                                                                      at android.os.Handler.dispatchMessage(Handler.java:106) 
                                                                                      at android.os.Looper.loop(Looper.java:164) 
                                                                                      at android.app.ActivityThread.main(ActivityThread.java:6494) 
                                                                                      at java.lang.reflect.Method.invoke(Native Method) 
                                                                                      at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438) 
                                                                                      at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807) 

Follow the Fragment >>>

package com.example.dutra_pc.myapplication;


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


/**
 * A simple {@link Fragment} subclass.
 */
public class Content_Ini extends Fragment {


    public Content_Ini() {
        // Required empty public constructor
    }


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

}

and File content_main2>>>

<?xml version="1.0" encoding="utf-8"?>
<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:id="@+id/content_ini"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.example.dutra_pc.myapplication.Main2Activity"
    tools:showIn="@layout/app_bar_main2">


</android.support.constraint.ConstraintLayout>
  • The layout content_main2 exists?

  • @Isac S I’ll even edit upstairs...

  • Bizarre solution I obtained was to create within the Constraintlayout another Constraintlayout and it worked perfectly... and I passed the id q was using in the external Constraintlayout to the internal now pq only funnel so will understand...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.