android - How do I programatically find the fragment currently being shown by a FragmentActivity? -


i need locate fragment being shown fragmentactivity.

alternatively, need find fragment implements given interface.

    public boolean oneditoraction(textview v, int actionid, keyevent event) {     if (editorinfo.ime_action_done == actionid) {         // return input text fragment         adjustpricesdialoglistener fragment = (adjustpricesdialoglistener) ??? // how find fragment? 

how accomplish ?

you have use fragment manager.

there 2 methods:

findfragmentbytag , findfragmentbyid

if pushed fragment layout can reference layout id.

the tag can null or set programmer before.

you can iterate through stack of fragment manager.

to supportfragmentmanager, write inside fragmentactivity:

getsupportfragmentmanager() 

Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -