sandee
sandee

Reputation: 23

Image of imageview not remove?

I have an ImageView after getting id from xml.as on ImageView we set clicklistener which open gallery and camera opetion you can set image from camera as well gallery ain #2

   profileimage = (ImageView) findViewById(R.id.profileimage);
    profileimage.setBackgroundResource(R.drawable.no_img);

  protected void onActivityResult(int requestCode, int resultCode,
        Intent intent) {
    super.onActivityResult(requestCode, resultCode, intent);
    if (resultCode == RESULT_CANCELED) {
        // TODO
        return;
    }
    Log.e("request code", "1:" + requestCode);
    switch (requestCode) {
    case CAMERA_SELECT:
        Log.e("in camera select", "1");
        // Get the camera data
        cameracalling(intent);

        break;
    case Gallery_Select:
        ongallerycalling(intent,resultCode);

    }
}

private void cameracalling(Intent intent){

     Bitmap photo = (Bitmap) intent.getExtras().get("data"); 
     profileimage.setImageBitmap(photo);
 }


profileimage.buildDrawingCache();

Bitmap bmap = profileimage.getDrawingCache();

ByteArrayOutputStream bao = new ByteArrayOutputStream();

bmap.compress(Bitmap.CompressFormat.JPEG, 90, bao);

byte [] ba = bao.toByteArray();

bitmapString=Base64.encodeBytes(ba);


Drawable draw = LoadImageFromWebOperations("" + objUserInformationSitesList.getProfileImage());

profileimage.setBackgroundDrawable(draw);   

We are sending bitmap string to server image upload on server properly but when we open next time this screen that webservice call on which we upload image which will give all data (actually this user profile screen) .when we set server image then default image also set on background

objUserInformationSitesList this object which contains all information after parsing the web service. behind profile image ,default image also looking which set by me on number #1

if I unable to explain properly then please tell me.

Upvotes: 0

Views: 684

Answers (2)

Karn Shah
Karn Shah

Reputation: 501

You should replace below line:

profileimage.setBackgroundResource(R.drawable.no_img);

with this line:

profileimage.setImageResource(R.drawable.no_img);

You set the image as the background of drawable and later you set bitmap as image source. So imageview background doesn't change. You should set image as image resource.

Upvotes: 1

user1203673
user1203673

Reputation: 1015

use in onclicklistener profileimage.setBackgroundResource(0);

Upvotes: 1

Related Questions