Hint Error: The method Replace in the type. Is isn't applicable for the argument ...

Source: Internet
Author: User

There was an error in the recent new fragment:

The method replace (int, Fragment) in the type fragmenttransaction are not applicable for the arguments (int, myfragment) new F When the Ragment

Fragment newfragment =new myfragment ();
Fragmenttransaction.replace (r.layout.activity_main,newfragment). commit ();

Hint Error: The method replace (int, Fragment) in the type fragmenttransaction are not applicable for the arguments (int, myfragmen T


Error code:

650 "this.width=650;" src= "http:// Common.cnblogs.com/images/copycode.gif "alt=" Copy Code "style=" Border:none; "/>

Package com.example.testforfragment;import android.os.bundle;import android.app.activity;import  android.app.FragmentManager;import android.app.FragmentTransaction;import  android.support.v4.app.fragment;import android.support.v4.app.fragment.*;import android.view.menu; public class mainactivity extends activity {     @Override      protected void oncreate (bundle savedinstancestate)  {         super.oncreate (savedinstancestate);         setcontentview (r.layout.activity_main);         fragmentmanager  fragmentmanager = getfragmentmanager ();         Fragmenttransaction  fragmenttransaction = fragmentmanager.begintransaction ();         fragment&nbsP;newfragment =new myfragment ();         Fragmenttransaction.replace (r.layout.activity_main,newfragment ). Commit ();    }      @Override     public boolean oncreateoptionsmenu (menu menu )  {        // Inflate the menu; this  adds items to the action bar if it is present.         getmenuinflater (). Inflate (R.menu.main, menu);         return true;    }}

650) this.width=650; "src=" Http://common.cnblogs.com/images/copycode.gif "alt=" Copy Code "style=" Border:none; "/>

Modify:

650) this.width=650; "src=" Http://common.cnblogs.com/images/copycode.gif "alt=" Copy Code "style=" Border:none; "/>

Package com.example.testforfragment;import android.os.bundle;import android.app.activity;import  android.support.v4.app.Fragment;import android.support.v4.app.FragmentActivity;import  android.support.v4.app.fragmentmanager;import android.support.v4.app.fragmenttransaction;import  android.view.menu;public class mainactivity extends fragmentactivity {      @Override     protected void oncreate (bundle savedinstancestate)  {        super.oncreate (savedinstancestate);         setcontentview (R.layout.activity_main);         fragmentmanager fragmentmanager = getsupportfragmentmanager ();         FragmentTransaction  fragmentTransaction =  Fragmentmanager.begintransaction ();          fragment newfragment =new myfragment ();         fragmenttransaction.replace (r.layout.activity_main,newfragment ). Commit ();     }     @Override     public boolean  Oncreateoptionsmenu (Menu menu)  {        // inflate  the menu; this adds items to the action bar if it  is present.        getmenuinflater (). Inflate (R.menu.main,  menu);         return true;    }}

650) this.width=650; "src=" Http://common.cnblogs.com/images/copycode.gif "alt=" Copy Code "style=" Border:none; "/>

In the wrong time has been unable to find the root cause, and then found on the Internet, found the problem point, transferred from http://www.cnblogs.com/1114250779boke/p/3867494.html

This article is from the "unity of Knowledge" blog, please be sure to keep this source http://poarry.blog.51cto.com/5970996/1570805

Hint Error: The method Replace in the type. Is isn't applicable for the argument ...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.