关键词:
// To set Default fragment to the activity
getSupportFragmentManager().beginTransaction()
.add(R.id.container, new fragmentName(), "fragmenrTag")
.commit();
//The Activity should implement the interfaces of all its fragments and its methods to get Data from the Fragment
//Adding Interface inside a fragment
private displayInterface mListener;
@Override
public void onAttach(Context context)
super.onAttach(context);
mListener = (displayInterface) context;
public interface displayInterface
void displayInterface(data data); //Call this method wherever necessary, implementation of this method will be in the Activity
//Sending data to a fragment before calling it
Bundle bundle = new Bundle();
bundle.putSerializable("data", data);
display myObj = new display();
myObj.setArguments(bundle);
getSupportFragmentManager().beginTransaction()
.replace(R.id.container, myObj, "display")
.addToBackStack(null)
.commit();
//Retrieving Data insinde the fragment
if (getArguments() != null)
user = (data) getArguments().getSerializable("data");
// Go back to previous Fragment
getActivity().getSupportFragmentManager().popBackStack();
text片段(代码片段)
查看详情
text代码片段很有用(代码片段)
查看详情
text代码片段【snl】(代码片段)
查看详情
text测试片段(代码片段)
查看详情
text主片段(代码片段)
查看详情
text片段沟通(代码片段)
查看详情
text测试片段(代码片段)
查看详情
text生活片段(代码片段)
查看详情
text数学片段(代码片段)
查看详情
text片段+的viewpage+片段(代码片段)
查看详情
text简单的片段(代码片段)
查看详情
text会话片段logan(代码片段)
查看详情
text应用程序片段(代码片段)
查看详情
text*+*(代码片段)
查看详情
text#(代码片段)
查看详情
text#(代码片段)
查看详情
text`(代码片段)
查看详情
text角代码(代码片段)
查看详情