Profilepictureを前に撮ることができる画像で設定しようとしています。これは断片に起こります。私のコードはアップし、これまでです:Android Studioのフラグメント内の画像を取り込めません
public class ProfileFragment extends Fragment {
CircleImageView profilepicture;
private static final int CAM_REQUEST = 1313;
public ProfileFragment() {
// Required empty public constructor
}
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_profile, container, false);
profilepicture = (CircleImageView) view.findViewById(R.id.profilepicture);
return view;
}
public void profilepictureOnClick(){
takeNewProfilePicture();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if(resultCode == Activity.RESULT_OK) {
if(requestCode == CAM_REQUEST){
Bitmap thumbnail = (Bitmap) data.getExtras().get("data");
profilepicture.setImageBitmap(thumbnail);
}
}
}
private void takeNewProfilePicture(){
Intent cameraintent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
startActivityForResult(cameraintent, CAM_REQUEST);
}
}
私はそのようにこれを実行すると、アプリケーションは、Iピクチャ、「最初の」フラグメント、ないProfilefragmentを受け入れた後、表示され、私はprofilefragmentに戻ったときに、 profilepictureは変更されていません。私はすでにブレークポイントを設定し、デバッグモードでそれを行った:プログラムはブレークポイントで停止しますが、私は "ステップオーバー"をクリックすると、それはリロードのようですが、それはまだ同じブレークポイントにあります...
すべてのアイデア?
ちょっと@tahsinRupam、まずはお手伝いをしていただきありがとうございます。私はあなたのコードを使用しましたが、結果は全く同じです – HansKrywaa
メソッドprofilepictureOnClick()が呼び出された場所から。あなたはあなたのアクティビティクラスを提供することができます、それは少し物事をクリアすることがあります。 – tahsinRupam
更新された回答を確認してください。 – tahsinRupam