I’m writing an app where I want to start with a View object and walk up the View hierarchy, using getParent() until I get all the way to ViewRoot, which I hope to detect using instanceof.
Seems simple enough, but I’m in trouble already because I can’t seem to import ViewRoot. On the line where I have:
import android.view.ViewRoot;
I get:
The import android.view.ViewRoot cannot be resolved
I’ve written dozens of apps in this environment, importing everything under the sun but I’ve never had a problem like this.
Eclipse 3.52, target is Android 2.2 and higher.
If you just need the top-level view, would
View.getRootView()give you what you need?