将数据从片段传递到另一个片段

时间:2015-09-01 13:39:07

标签: android android-fragments

这是我的Fragment_vent。如何将数据从Fragment_vent传递到另一个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();
}

2 个答案:

答案 0 :(得分:1)

使用以下代码......

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

并将片段作为..

 getArguments().getString("value1");    
 getArguments().getString("value2"); 

答案 1 :(得分:0)

QMenu