I need to create one textview array, i’d like to show or hide one image depending position.
I’ll try to explain it:
I’ve one layout similar this:
1 2 3 4 5
And depending random value show or hide an image in textview 1 or 2, etc…
I can use:
if (a == 4)
{
t4.setBackgroundResource(R.drawable.ficha);
t1.setBackgroundDrawable(null);
t2.setBackgroundDrawable(null);
t3.setBackgroundDrawable(null);
t5.setBackgroundDrawable(null);
}
else if (a==5)
...
..
But i’d like to know, if it’s possible to pass the number t(1) using parameters or something similar.
Thanks in advance and sorry about my english.
Or you can use
List<TextView> tvList = new ArrayList<TextView>();add as many textviews as you like
and this will retrieve a textview and set background from a list depending on your
avalue :1st 2nd and so on. you can use Arrays too of course for this purpose.
hope it helps abit