This is my Fragment_vent
. How can I pass data from Fragment_vent
to another Fragment
? (putExtra("ext",IDV_L))
@Override
public void onClick(View v) {
IDV_L = date();
Fragment fragment = null;
fragment = new Fragment_Inicio_Tab();
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.frame_container, fragment).commit();
}
Use below code...
Fragment fragment = null;
fragment = new Fragment_Inicio_Tab();
Bundle args = new Bundle()
args.putString("value1", value1);
args.putString("value2", value2);
fragment.setArguments(args);
FragmentManager fragmentManager = getFragmentManager();
fragmentManager.beginTransaction()
.replace(R.id.frame_container, fragment).commit();
and get in fragment as..
getArguments().getString("value1");
getArguments().getString("value2");
Bundle bundle=new Bundle();
bundle.putString("message", "From Activity");
//set Fragmentclass Arguments
Fragmentclass fragobj=new Fragmentclass();
fragobj.setArguments(bundle);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.