Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call activity from another fragment.?

I already know how to make a fragment in Android. I want to open another activity in the same fragment on a button click event. The button is inside a fragment class.

How do I do that?

like image 553
Saeed V. Avatar asked Jul 15 '11 11:07

Saeed V.


1 Answers

There are two possibilities depending on what you need:

  • Fragment Receive Result that demonstrates starting a new Activity from a Fragment, and receiving a result back from it.
  • setTargetFragment may be used, for example, if this fragment is being started by another, and when done wants to give a result back to the first. An example is available here
like image 147
Niqo Avatar answered Oct 17 '22 18:10

Niqo