我想将Fragmap中的Bitmap传递给MainActivity。我想保存位图,即“image = a.getParcelable(”BITMAP“);”在ActionBar按钮上单击。为此,我需要在MainActivity中使用此图像。我怎么能这样做?
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// TODO Inflate the layout for this fragment
setHasOptionsMenu(true);
Bundle a = getArguments();
image = a.getParcelable("BITMAP");
View v = inflater.inflate(R.layout.main_layout, container, false);
qImage = (ImageView) v.findViewById(R.id.qImage);
qImage.setImageBitmap(image);
return v;
}
答案 0 :(得分:1)
在MainActivity中
Bitmap a;
在片段中
MainAcivity main;
main = (MainActivity)getActivity();
main.a = image
或调用MainActivity上的方法来更新位图