I have a dynamically created View and want to find it by tag, is this possible?
I know the function findViewById
, is there something similar for tags?
LinearLayout linLayout = (LinearLayout)findViewWithTag("layout1");
but I don't think you need tag for dynamic view. You can retrieve dynamic resource by following code
for (int i=0; i < total_resource; i++) {
//retrieve id dynamically
int id = getResources().getIdentifier("resource"+i, "id", getPackageName());
TextView myText = (TextView) findViewById(id); // get the element
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With