How do I call findViewWithTag in the OnCreate() method of an activity?

android

Solution

`findViewWithTag()` is only defined for a View.

If you have a reference to the contentView of the activity that you set with `setContentView(contentView)`, you can use `contentView.findViewWithTag()`.

If you don't have a reference to that view, you can also use `findViewById(R.id.your_content_view_id).findViewWithTag(tag)`.

Problem

I get an error when I call `findViewWithTag()` in the `onCreate()` "The method `findViewWithTag(String)` is undefined for the type MainActivity" Is there any alternative?

Original source