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