Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inserting the current year into a TextView

Tags:

date

android

Just a small problem really, I want to place the current year into the footer of my apps. Each footer is a TextView, which is seen on menu screens etc. Is there a way to insert the year into this dynamically?

Cheers, Laurence

like image 986
Ljdawson Avatar asked Feb 06 '10 22:02

Ljdawson


People also ask

How do I enter TextView?

for the new line in TextView just add \n in middle of your text it works..

Can we change the text in TextView?

TextView tv1 = (TextView)findViewById(R. id. textView1); tv1. setText("Hello"); setContentView(tv1);

Which attribute is used to show any text inside TextView?

We use attribute android: hint= "Text will show here", so if we will set the TextView in the MainActivity.


1 Answers

You can do something like:

Calendar calendar = Calendar.getInstance(); int year = calendar.get(Calendar.YEAR);  TextView footer = findViewById(R.id.footer); footer.setText("" + year); 
like image 79
Erich Douglass Avatar answered Sep 16 '22 16:09

Erich Douglass