Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Button player = (Button) setBg.findViewById(R.id.plBg);
- player.setOnClickListener(new OnClickListener() {
- public void onClick(View v) {
- Intent i = new Intent(Intent.ACTION_PICK,
- android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
- i.setDataAndType(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, "image/*");
- startActivityForResult(i, RESULT_LOAD_PLAYER);
- setBg.dismiss();
- }
- });
- @Override
- protected void onActivityResult(int requestCode, int resultCode, final Intent data) {
- super.onActivityResult(requestCode, resultCode, data);
- if (requestCode == RESULT_LOAD_PLAYER && resultCode == RESULT_OK && null != data) {
- Uri selectedImage = data.getData();
- String[] filePathColumn = {MediaStore.Images.Media.DATA};
- Cursor cursor = getContentResolver().query(selectedImage,
- filePathColumn, null, null, null);
- cursor.moveToFirst();
- int columnIndex = cursor.getColumnIndex(filePathColumn[0]);
- String picturePath = cursor.getString(columnIndex);
- cursor.close();
- playerBg = (ImageView) findViewById(R.id.playerBg);
- playerBg.setImageBitmap(BitmapFactory.decodeFile(picturePath));
- playerBg.setScaleType(ScaleType.CENTER_CROP);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement