Skip to content

Instantly share code, notes, and snippets.

@KUNAL1612
Forked from udacityandroid/TextView.java
Created October 11, 2017 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save KUNAL1612/40b19517b66a2a37d802a74e82c1c42c to your computer and use it in GitHub Desktop.
Save KUNAL1612/40b19517b66a2a37d802a74e82c1c42c to your computer and use it in GitHub Desktop.
Android for Beginners : Simplified TextView class
/**
* Displays text to the user.
*/
public class TextView extends View {
// String value
private String mText;
// Text color of the text
private int mTextColor;
// Context of the app
private Context mContext;
/**
* Constructs a new TextView with initial values for text and text color.
*/
public TextView(Context context) {
mText = "";
mTextColor = 0;
mContext = context;
}
/**
* Sets the string value in the TextView.
*
* @param text is the updated string to be displayed.
*/
public void setText(String text) {
mText = text;
}
/**
* Sets the text color of the TextView.
*
* @param color of text to be displayed.
*/
public void setTextColor(int color) {
mTextColor = color;
}
/**
* Gets the string value in the TextView.
*
* @return current text in the TextView.
*/
public String getText() {
return mText;
}
/**
* Gets the text color of the TextView.
*
* @return current text color.
*/
public int getTextColor() {
return mTextColor;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment