android - how to use string as reference in java? -


this question has answer here:

i have edittext reference set "dimrix_1" . have string has value "dimrix_1" .

how can use string reference in case dont know value of string if "dimrix_2" refer "dimrix_2" edittext , on ...

dimrix_1 = (edittext) mroot         .findviewbyid(r.id.dimrix_et); dimrix_2 = (edittext) mroot         .findviewbyid(r.id.dimrix2_et); dimrix_3 = (edittext) mroot         .findviewbyid(r.id.dimrix3_et);   string mannotneeded = "dimrix_" + totalnumbers; 

now want go make edittext match "mannotneeded" value setvisibility(view.gone)

hope clear on explanation ...

update :

            int r = getresources().getidentifier(                     "edit_text_id", "id",                     getactivity().getpackagename()); dimrix_1 = (edittext) mroot         .findviewbyid(r); 

this suggest here don't want use original xml id . want use reference if possible.

the method android.content.res.resources.getidentifier() want. details have @ documentation


Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -