从活动开始的片段 [英] Start a fragment from an activity
本文介绍了从活动开始的片段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我米试图从这样的
public void btn (View view)
{
Intent intent1 = new Intent(this, F5_fr.class);
startActivity(intent1);
}
我在我的xml一个onclick的事情用BTN
i have an Onclick thing in my xml with the "btn" :
的片段名F5_fr.class
Fragment 's name is F5_fr.class
在此先感谢
推荐答案
请检查下面code片断:
Please check below code snippet :
FragmentManager fragmentManager = getFragmentManager();
FragmentTransaction fragmentTransaction =
fragmentManager.beginTransaction();
YourFragment fragment = new YourFragment();
fragmentTransaction.replace(android.R.id.content, fragment);
全球化志愿服务青年的链接 - 这个。
在这里你会得到碎片的想法。你可以在这里看到如何从一个活动叫一个片段。
Referance link - this. here you will get idea of fragments . you can see here how to call a fragments from an activity.
这篇关于从活动开始的片段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文