I have a xml layout that will display a grid of text views in tabulars. Text view names are celland, cell 01, in order, my program will determine which cell to change.
Is there a way to format the name so that it can be passed in the findViewById method at runtime? For example, if celland is needed, then how can I generate a parm in this code?
Find textview cursele = (textview) VVBiID (RIDC0000)
Some "cells" like +00 do not compile because findViewById method String does not accept type. In the hardcoded grid in the program, I do not want the name of every text view - should be a better way
Thank you for any help.
You can use reflection to find the integer value of a named variable in RDI.
class clause = red Class; Field F = Clause.Getfield ("cell" + "00"); Int id = f.getInt (faucet); // Pass in the blank, because the field is a static field text view currcell = (TextView) findViewById (ID); Keep in mind that reflection may be slow if you do a lot of things, you can cache prices or come in a different way.
Comments
Post a Comment