How we can Call a FragmentActivity from a FragmentActivity in Android
-
21-12-2019 - |
Question
How can we call a FragmentActivity
from a FragmentActivity
on click of button .Please help me in this .
And please help me to understand the difference between FragmentActivity
and Fragment
Solution
Similar way what we are doing with Activities
button1.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
startActivity(new Intent(FragmentActivity1.this, FragmentActivity2.class));
}
});
OTHER TIPS
FragmentActivity
is the base class for activities that want to use the support-based Fragment
and Loader APIs.
So if you are using fragment below api level 11 you should use Fragment from the support library in which case your activity extends FragmentActivity
If you are using fragment in api level 11 and above you use Fragment and extend Activtiy.
Fragment is hosted by a Activity. You can't call a Activtiy. You can start another Activity from fragment or activity.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow