我有第一个用Picasso以这种方式加载imageView的片段:
ExifInterface exif = null;
float rotate = 0;
try
{
exif = new ExifInterface(absolutePath);
} catch (IOException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
int orientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION,
ExifInterface.ORIENTATION_UNDEFINED);
switch (orientation) {
case ExifInterface.ORIENTATION_NORMAL:
rotate = 0;
break;
case ExifInterface.ORIENTATION_ROTATE_270:
rotate = 270;
break;
case ExifInterface.ORIENTATION_ROTATE_180:
rotate = 180;
break;
case ExifInterface.ORIENTATION_ROTATE_90:
rotate = 90;
break;
}
Picasso.with(getActivity())
.load(mMediaUri)
.resize(1280, 1280)
.rotate(rotate)
.centerCrop()
.transform(new RoundedTransformation())
.into(photo);
当我按下next
按钮时,我执行此操作,然后转到第二个片段:
Bundle bundle = new Bundle();
bundle.putLong("primaryKey", primaryKey);
bundle.putString("uri", String.valueOf(mMediaUri));
bundle.putString("registration", registrationET.getText().toString().trim());
bundle.putString("makemodel", makemodelET.getText().toString().trim());
bundle.putString("manifacturer", manifacturerET.getText().toString().trim());
bundle.putString("category", categoryET.getText().toString().trim());
bundle.putString("class", classET.getText().toString().trim());
Fragment fragment = new AddAircraftSecondPartFragment();
fragment.setArguments(bundle);
FragmentManager manager = getActivity().getSupportFragmentManager();
manager.beginTransaction().replace(R.id.content_main, fragment).addToBackStack(null).commit();
当我想要按回或点击Back
按钮时会出现问题:EditText
或TextView
上的值是正确的,因为我使用了这个:
android:freezesText="true"
但我没有在ImageView中看到先前的图像加载了Picasso。
这是我用于popBackStack()
的代码:
private void pressBackButton()
{
FragmentManager manager = getActivity().getSupportFragmentManager();
manager.popBackStack();
}
所以我的问题是:
popBackStack()
之后的前一个片段中调用的方法是什么?感谢您的回答
答案 0 :(得分:1)
1)您可以移动图像加载以覆盖片段的onResume()方法。
2)当片段被"恢复时,调用onResume()"