Skip to content

Instantly share code, notes, and snippets.

@udacityandroid
Created June 15, 2015 18:24
Show Gist options
  • Save udacityandroid/bd550cc8fd37190d85a6 to your computer and use it in GitHub Desktop.
Save udacityandroid/bd550cc8fd37190d85a6 to your computer and use it in GitHub Desktop.
Android for Beginners : Simplified ImageView class
/**
* Displays an image, such as an icon.
*/
public class ImageView extends View {
// Resource ID for the source image that should be displayed in the ImageView.
private int mImageId;
// Context of the app
private Context mContext;
/**
* Constructs a new ImageView.
*/
public ImageView(Context context) {
mImageId = 0;
mContext = context;
}
/**
* Sets the source image in the ImageView.
*
* @param imageId is the resource ID of the image to be displayed.
*/
public void setImage(int imageId) {
mImageId = imageId;
}
}
@chayanbobra13
Copy link

helpful

@Eduese
Copy link

Eduese commented May 21, 2018

Seems errors noticed by our predecessors have been corrected. Nice work

@tooptooptoop
Copy link

Thanks.

@moiyd
Copy link

moiyd commented Sep 29, 2018

thanks

@nurbijoy
Copy link

Thanks

@djalilo24
Copy link

TNX

@YassineOuardini
Copy link

thanks ♥

@avinabX
Copy link

avinabX commented Aug 11, 2019

please can anyone explain why the member variables they used were declared private access modifier
private int mImageId;

**private** Context mContext;

@LaszloLajosT
Copy link

please can anyone explain why the member variables they used were declared private access modifier
private int mImageId;

**private** Context mContext;

I copied the answer from the other site:

What is difference between Private and Protected?

Private get only used in his class , but protected can used in his class and in the same package and derived class

@faroukelhamdi
Copy link

Was here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment