从活动开始的片段
问题描述:
我米试图从这样的
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.