0

I try load Image when click Image Button in android, the app intent to the memory but can't Load Img to Img Button in app , this screen show!

enter image description here

 int GALARY_REQUEST = 2;
    private Uri url=null;
    ImageButton imageButton ;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_post);

        Button submut = (Button) findViewById(R.id.but_submet);
        imageButton = (ImageButton) findViewById(R.id.img_butt);
        imageButton.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent galleryIntent = new Intent(Intent.ACTION_GET_CONTENT);
                galleryIntent.setType("Image/*");
                startActivityForResult(galleryIntent,GALARY_REQUEST);
    }
    });
   }


    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        super.onActivityResult(requestCode, resultCode, data);

        if (requestCode== GALARY_REQUEST && requestCode==RESULT_OK){
            url=data.getData();
            imageButton = (ImageButton) findViewById(R.id.img_butt);
            imageButton.setImageURI(url);

        }
    }
  • https://stackoverflow.com/a/38352844/6490462 This will help. –  Oct 30 '17 at 19:42
  • You can use Glider or picass of google lib for same it will be usefull in your case http://tutorialwing.com/android-glide-library-tutorial-example/ – Akash kumar Oct 30 '17 at 20:02

0 Answers0