M
M
Maybe_V2016-04-08 18:30:51
Android
Maybe_V, 2016-04-08 18:30:51

How to assign target fragment not in fragment class?

I have an adapter for an ExpandableList, it makes a listView on a TaskList fragment, and in the adapter, when the child is clicked, a new TaskDialog fragment opens.
I need to target a TaskList for a TaskDialog!
If this is done in the fragment class, then there are no problems, but when I do it in the adapter class, an error occurs!

TaskDialog taskDialog = TaskDialog.newInstance(name);
        taskDialog.setTargetFragment(TaskList.class, REQUEST_ADD_TASK_CODE);
        taskDialog.show(context.getSupportFragmentManager(), TASK_DIALOG_FLAG);


Is it possible to do this in a class that is not a fragment?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Denis Zagaevsky, 2016-04-08
@prokopov-vi

setTargetFragment() takes an instance of the Fragment class as input, and you push the class to it. Of course, this cannot be done, you need to transfer a specific object. From what class it will be made (from a fragment, adapter, etc.) - all the same.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question