Skip to content

Instantly share code, notes, and snippets.

@udacityandroid
Created June 15, 2015 18:23
Show Gist options
  • Select an option

  • Save udacityandroid/47592c621d32450d7dbc to your computer and use it in GitHub Desktop.

Select an option

Save udacityandroid/47592c621d32450d7dbc 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;
}
}
@arsalanfakhar

Copy link
Copy Markdown

Was here in 2019

@djalilo24

Copy link
Copy Markdown

nICE

@Alaaba98

Alaaba98 commented Apr 2, 2019

Copy link
Copy Markdown

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

@djalilo24

Copy link
Copy Markdown

niceeee

@1998tapan

Copy link
Copy Markdown

I still have error, help please ?!
13

late, but you are missing one closing bracket "}"

@hamzagamal

Copy link
Copy Markdown

good

@mansourhas

Copy link
Copy Markdown

2019
this course still relevant!!!

@adyapy

adyapy commented Dec 29, 2019

Copy link
Copy Markdown

2019
this course still relevant!!!

Yes, very much! If a syntax is deprecated or changed in newer versions of android, android studio will help you with that. But those are very rare in this course. So don't worry, it is still very relevant :)

@collinsnkem

Copy link
Copy Markdown

This is 2020...

This course might be outdated but it's still very relevant...
I was Here...

@felhamdi

felhamdi commented May 9, 2020

Copy link
Copy Markdown

Was here! 💯

@SDIDSA

SDIDSA commented May 18, 2020

Copy link
Copy Markdown

the course is still very relevant imo, it's very professional

@Khusinov

Copy link
Copy Markdown

It is brilliant))

@mohmed899

Copy link
Copy Markdown

what dose " @param" mean?

@humandroid01

Copy link
Copy Markdown

Hello everyone!
Was here 17/07/2020.

@Asadbek-IP

Copy link
Copy Markdown

perfect

@enockkays

Copy link
Copy Markdown

@bnil53 # https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html
this is Controlling Access to Members of a Class

This link to the java documentation is very helpful, thanks for sharing.

@shiv-am2608

Copy link
Copy Markdown

super(context);

Thanks!!

@hap2y1122

Copy link
Copy Markdown

What is difference between Private and Protected?

Private is something like variables or methods you can only access inside the class
Protected is accessible only with the help of child class.

@Mina-kameel

Copy link
Copy Markdown

Hi All
Why We Create Custom Class (Word)

@hap2y1122

Copy link
Copy Markdown

Hi All
Why We Create Custom Class (Word)

So we can create our own customized view and use it whereever needed.

@Mina-kameel

Copy link
Copy Markdown

Hi All
Why We Create Custom Class (Word)

So we can create our own customized view and use it whereever needed.

Thanks
Can we create a Custom Class without Definition of Constructor?

@hap2y1122

Copy link
Copy Markdown

Hi All
Why We Create Custom Class (Word)

So we can create our own customized view and use it whereever needed.

Thanks
Can we create a Custom Class without Definition of Constructor?

No constructor is needed to define its basic property.

@its-ud

its-ud commented Jun 21, 2021

Copy link
Copy Markdown

thanks for the documentation

@ytsaxena

ytsaxena commented Sep 1, 2021

Copy link
Copy Markdown

Where i have to write this i am not getting any idea

@Ritik101

Ritik101 commented Sep 8, 2021

Copy link
Copy Markdown

Where i have to write this i am not getting any idea

Right click on com.firstapp.miwok and create a java class
Screenshot (6)

@Oussma77

Oussma77 commented May 5, 2022

Copy link
Copy Markdown

interesting

@Anvarbest89

Copy link
Copy Markdown

was here 2022

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