문제

Is it possible for an Activity to get to and inspect, ideally even modify, the entire View hierarchy for itself, without knowing IDs of all the views or special access such as instrumentation mode or rooting?

E.g. would it be possible to write some code that locates all, say, EditText instances in the Activity's View hierarchy and does something to them?

Thanks

도움이 되었습니까?

해결책

Is it possible for an Activity to get to and inspect, ideally even modify, the entire View hierarchy for itself, without special access such as instrumentation mode or rooting?

findViewById(android.R.id.content) returns the View that hosts the content you supplied in setContentView(). Beyond that, try getRootView() (called on any View) to retrieve "the topmost view in the current view hierarchy".

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top