java - Wrong 2nd argument type found 'com.technology.computer.mit.ctechmit.Menu_pageFragment' required 'Android.app.Fragment' -


i have written code fragment replacement on click of send button. code shows error saying

wrong 2nd argument type found 'com.technology.computer.mit.ctechmit.menu_pagefragment' required 'android.app.fragment'

in below line under word 'newfragment'

transaction.replace(r.id.fragment_container, newfragment);

when searched solution online says extend fragmentactivity instead of extending fragment. if home_activity (one has no errors) shows many errors. can please suggest me solution this?

below home_pagefragment in sendmessage method replaces menu_pagefragment on click of send method in layout:

package com.technology.computer.mit.ctechmit;  import android.app.fragmenttransaction; import android.support.v4.app.fragment; import android.os.bundle; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup;  /**  * placeholder fragment containing simple view.  */ public class home_pagefragment extends fragment {      public void sendmessage(view view) {         // in response button // create fragment , give argument specifying article should show         menu_pagefragment newfragment = new menu_pagefragment();         bundle args = new bundle();         //args.putint(menu_pagefragment.arg_position, position);         newfragment.setarguments(args);          fragmenttransaction transaction = getactivity().getfragmentmanager().begintransaction();  // replace whatever in fragment_container view fragment, // , add transaction stack user can navigate         transaction.replace(r.id.fragment_container, newfragment);         transaction.addtobackstack(null);  // commit transaction         transaction.commit();      }     @override     public view oncreateview(layoutinflater inflater, viewgroup container,                              bundle savedinstancestate) {          // inflate layout fragment         return inflater.inflate(r.layout.fragment_home_page, container, false);     }  } 

below home_page fragment-container code (has no errors):

package com.technology.computer.mit.ctechmit;  import android.support.v7.app.actionbaractivity; import android.os.bundle; import android.view.menu; import android.view.menuinflater; import android.view.menuitem;   public class home_page extends actionbaractivity {      @override     protected void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.activity_home_page);         // create new fragment placed in activity layout         home_pagefragment firstfragment = new home_pagefragment();         // in case activity started special instructions         // intent, pass intent's extras fragment arguments         firstfragment.setarguments(getintent().getextras());         // add fragment 'fragment_container' framelayout         getsupportfragmentmanager().begintransaction()                 .add(r.id.fragment_container, firstfragment).commit();       }       @override     public boolean oncreateoptionsmenu(menu menu) {         // inflate menu items use in action bar         menuinflater inflater = getmenuinflater();         inflater.inflate(r.menu.menu_home_page, menu);         return super.oncreateoptionsmenu(menu);     }      public void opensearch() {      }      public void opensettings() {      }      @override     public boolean onoptionsitemselected(menuitem item) {         // handle presses on action bar items         switch (item.getitemid()) {             case r.id.action_search:                 opensearch();                 return true;             case r.id.action_settings:                 opensettings();                 return true;             default:                 return super.onoptionsitemselected(item);         }      } } 

here menu_pagefragment :

package com.technology.computer.mit.ctechmit;  import android.os.bundle; import android.support.v4.app.fragment; import android.view.layoutinflater; import android.view.view; import android.view.viewgroup;   /**  * simple {@link fragment} subclass.  */ public class menu_pagefragment extends fragment {       public menu_pagefragment() {         // required empty public constructor     }       @override     public view oncreateview(layoutinflater inflater, viewgroup container,                              bundle savedinstancestate) {         // inflate layout fragment         return inflater.inflate(r.layout.fragment_menu_page, container, false);     }   } 

can please me this?

it looks you're trying change fragment fragment... try using getchildfragmentmanager().


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -