Fragment和Activity的传值方法

public static MyOrderListFragment getInstance(String orderStatus) {
    MyOrderListFragment fragment = new MyOrderListFragment();
    Bundle bundle = new Bundle();
    bundle.putString("OrderStatus", orderStatus);
    fragment.setArguments(bundle);
    return fragment;
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    Bundle bundle = getArguments();
    if (bundle != null){
        mOrderStatus = bundle.getString("OrderStatus");
    }
}

你可能感兴趣的:(android)