Note that there are some explanatory texts on larger screens.

plurals
  1. POFragment add or replace not working
    primarykey
    data
    text
    <p>I'm using the code from this <a href="http://developer.android.com/guide/components/fragments.html" rel="noreferrer">reference.</a></p> <p>When I put in that code in my program I get an error as seen in the picture below. <img src="https://i.stack.imgur.com/RpgnS.png" alt="enter image description here"></p> <p>Any reasons for the error? <code>The method replace(int, Fragment) in the type FragmentTransaction is not applicable for the arguments (int, ExampleFragments)</code></p> <p>Code from my main activity:</p> <pre><code>public void red(View view) { android.app.FragmentManager fragmentManager = getFragmentManager(); android.app.FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction(); ExampleFragments fragment = new ExampleFragments(); fragmentTransaction.replace(R.id.frag, fragment); fragmentTransaction.commit(); } </code></pre> <p>ExampleFragments.java</p> <pre><code>package com.example.learn.fragments; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; public class ExampleFragments extends Fragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { // Inflate the layout for this fragment return inflater.inflate(R.layout.blue_pill_frag, container, false); } } </code></pre> <p>Here:</p> <pre><code>package com.example.learn.fragments; import android.app.Activity; import android.os.Bundle; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentTransaction; import android.view.LayoutInflater; import android.view.Menu; import android.view.View; import android.view.ViewGroup; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload