I am making a word game in which each a user has multiple guesses, each one made up of multiple TextViews. So far my code reads:
TextView[] guess1 = new TextView[numTextViews]; guess1[0] = (TextView) findViewById(R.id.Guess1_1); guess1[1] = (TextView) findViewById(R.id.Guess1_2); guess1[2] = (TextView) findViewById(R.id.Guess1_3); guess1[3] = (TextView) findViewById(R.id.Guess1_4); guess1[4] = (TextView) findViewById(R.id.Guess1_5); with the xml looking like:
<TextView android:id="@+id/Guess1_1" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_weight="1" android:gravity="center" android:text="@string/guessChar" />... which repeats with android:id= changing.
I am going to be repeating myself if I type out TextView[] guess2 and all its elements.
- What is a better way to go about this?
- Would it be better to create all the TextViews programmatically as they are so similar?