简体   繁体   English

我们如何从Android中的FragmentActivity调用FragmentActivity

[英]How we can Call a FragmentActivity from a FragmentActivity in Android

How can we call a FragmentActivity from a FragmentActivity on click of button .Please help me in this . 我们怎么能说一个FragmentActivityFragmentActivity按钮的点击。请帮我在这。

And please help me to understand the difference between FragmentActivity and Fragment 并且请帮助我了解FragmentActivityFragment之间的区别

FragmentActivity is the base class for activities that want to use the support-based Fragment and Loader APIs. FragmentActivity是要使用基于支持的Fragment和Loader API的活动的基类。

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 因此,如果您使用的是API级别11以下的片段,则应使用支持库中的Fragment,在这种情况下,您的活动将扩展FragmentActivity

If you are using fragment in api level 11 and above you use Fragment and extend Activtiy. 如果您在api级别11及更高级别中使用片段,则可以使用Fragment并扩展Activtiy。

Fragment is hosted by a Activity. 片段由活动托管。 You can't call a Activtiy. 您无法调用Activtiy。 You can start another Activity from fragment or activity. 您可以从片段或活动开始另一个活动。

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));
   }
});

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM