java - how to call method of one fragment from another fragment class in android -


i want call method of fragmentb (class) fragmenta tried making object of fragmentb in fragmenta (class) it's not working here code of fragmenta in class have method through call method of fragmentb class

adddata.setonclicklistener(         new view.onclicklistener() {         @override         public void onclick(view v) {             boolean isinserted = mydb.addalldata(monthly_income.gettext().tostring(),                 room_rent.gettext().tostring(),                 mess_rent.gettext().tostring());             if (isinserted = true)                 toast.maketext(getactivity().getbasecontext(), "data inserted", toast.length_long).show();             else             toast.maketext(getactivity().getbasecontext(), "data not inserted", toast.length_long).show();         }     } ); 

i want call method of fragmentb

public void show() {     cursor res = mydb.getalldata();     stringbuffer buffer = new stringbuffer();     while (res.movetonext()) {         displayresult.settext( buffer.append( res.getstring(1)));     } } 

i tried writing code in method of fragmenta getting error

fragmenta fragment=               (fragmenta)getsupportfragmentmanager().findfragmentbyid(r.id.pageview2);     ((fragmenta)fragment).show(); 

try solution:

((fragmenta) getactivity()     .getsupportfragmentmanager()     .findfragmentbyid(r.id.pageview2) ).show(); 

Comments

Popular posts from this blog

html - Firefox flex bug applied to buttons? -

html - Missing border-right in select on Firefox -

python - build a suggestions list using fuzzywuzzy -