1

i just want to know which equalitive equivalence to

Document.getElementsByClassName()

this in javascript i know this only

TextView m = (TextView)findViewById(R.id.mm);

but how can i get multi

TextView

with same something like class not id in android its will show error if there are same id in same layout so i can get array of view (TextView) and make loop on them and update them all

i just want to know how to do it in android

medo
  • 479
  • 3
  • 9
  • 24

1 Answers1

1

There is no good equivalent in android to finding elements by class as you can in an html dom. You have to get individual views by id and effect each of their properties, or get a container view that has the views you want to modify and iterate through them. If you can give us the specific use case that you want to do this for, we can guide you to the android appropriate way to do it.

That being said, you can use the tag attribute of views similar to how classes are used in html but you will only be able to set one tag per view and the process to find the views with the given tag will be very intensive. You can look at this SO post to see how it is done.

Community
  • 1
  • 1
Dr. Nitpick
  • 1,662
  • 1
  • 12
  • 16