答案 0 :(得分:0)
为此使用POJO课程。
发送......
YourNewFragment ldf = new YourNewFragment ();
Bundle args = new Bundle();
args.putExtra("DATA", POJO_MODEL);
ldf.setArguments(args);
//给片段充气 getFragmentManager()。beginTransaction()。add(R.id.container,ldf).commit();
接收......
POJO_MODEL pojo_model = POJO_MODEL_CAST)getArguments().getSerializable("DATA");
答案 1 :(得分:0)
使用Bundle发送字符串:
//输入值
YourNewFragment ldf = new YourNewFragment ();
Bundle args = new Bundle();
args.putString("YourKey1", "YourValue");
args.putString("YourKey2", "YourValue");
ldf.setArguments(args);
//给片段充气
getFragmentManager().beginTransaction().add(R.id.container, ldf).commit();
在新片段的onCreateView中:
//检索值
String value = getArguments().getString("YourKey");
答案 2 :(得分:0)
使用fit
发送数据:
def generator(features, labels, size):
while True:
start, end = 0, size
while end < len(features):
s = slice(start, end)
# you can actually do the normalization here if you want
yield features[s], labels[s]
start, end = end, end + size
model.fit_generator(
generator(x_train, y_train, batch_size),
steps_per_epoch=len(x_train) // batch_size,
epochs=1,
verbose=1,
validation_data=generator(x_test, y_test, batch_size),
validation_steps=len(x_test) // batch_size,
shuffle=False)
和score = model.evaluate_generator(
generator(x_test, y_test, batch_size),
steps=len(x_test) // batch_size)
类Bundle
方法:
Bundle bundle = new Bundle();
bundle.putString("key", "value");
// set Fragmentclass Arguments
CarDetailsFragment carDetailsFragment = new CarDetailsFragment();
carDetailsFragment.setArguments(bundle);
//replace fragment
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.replace(R.id.fragment_container, carDetailsFragment);
transaction.addToBackStack(null);
transaction.commit();
答案 3 :(得分:-1)