时,on resume()被调用。
i具有第一个片段,该片段的图像视图以这种方式加载了picasso:
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"
,但我看不到图像视图中加载的毕加索的上一个图像。这是我用来 popBackStack()
的代码:
private void pressBackButton()
{
FragmentManager manager = getActivity().getSupportFragmentManager();
manager.popBackStack();
}
所以我的问题是:
- 我该如何解决ImageView的问题?
-
popBackStack()
之后的上一个片段中所调用的方法是什么?
谢谢您的答案
1)您可以将图像加载移至片段的覆盖方法。
2)当片段"恢复"