First of all i want make edit photo profile. i use two fragment, Accountfragment and Bottom_sheet fragment. In my problem is i want pass the selected image from library and display at Accountfragment. In Bottom_sheet fragment i have pass the String, actually my problem is to callback. i have done follow the another method but not fully show this, how to call back in secondfragment. I don't know to declare in AccountFragment. Call from method ? or just declare in onCreateView? Can anyone show how to do the method to callback image from Bottom_sheet fragment.
This AccountFragment.class
@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater,
@Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View rootView = inflater.inflate(R.layout.fragment_account, container, false);
backbutton1 = (ImageView) rootView.findViewById(R.id.backbutton1);
imgprofile = (ImageView) rootView.findViewById(R.id.profileimage);
backbutton1.setOnClickListener(onClickListener);
imgprofile.setOnClickListener(onClickListener);
return rootView;
}
private View.OnClickListener onClickListener = new View.OnClickListener() {
@Override
public void onClick(View view) {
if(view == backbutton1) {
startActivity(new Intent(getActivity().getApplicationContext(), sidemenu.class));
getActivity().overridePendingTransition(R.anim.slide_in_left, R.anim.slide_out_right);
}if(view == imgprofile){
Bottom_sheet bottom_sheet = new Bottom_sheet();
bottom_sheet.show(getFragmentManager(), "examplebottomsheet");
}
}
};
This how i pass image from Bottom_sheet fragment.
@Override
public void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
if (resultCode == RESULT_OK && requestCode == IMAGE_PICK_CODE){
Uri uri = data.getData();
Intent intent=new Intent(getContext(), AccountFragment.class);
intent.putExtra("imageUri", uri.toString());
}
}
Sorry i'm newbie , a lot to study android