[英]Android: get Viewgroup from the view?
有沒有辦法從視圖中獲取ViewGroup? 我正在嘗試創建自定義數組適配器,它需要viewgroup
根據您所使用的ViewGroup
,您可以獲取視圖的父級並將其ViewGroup
轉換為ViewGroup
:
(ViewGroup)view.getParent() // this can be done to get any level in your view hierarchy
或者您可以將視圖本身轉換為ViewGroup
:
(ViewGroup)view
基本上,在視圖層次結構中找到所需的視圖並將其ViewGroup
為ViewGroup
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.