As an exercise, I am building a calendar. Below is a small segment of my code. I have a class
MyCalendar
that extends Activity.
This Activity will be linked to an XML file whose layout includes seven TextView
s with id
s R.id.day0
thru R.id.day6
.
If converted from String
to int
, will the Activity's findViewById()
method recognize the int
version of these id
s?
String Days [] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
TextView dayViews [];
private void populateViews (){
for (int counter = 0; counter < Days.length; counter++){
int ID = Integer.parseInt("R.id.day"+counter);
dayViews [counter] = (TextView) findViewById(ID);
dayViews[counter].setText(Days[counter]);
}