簡體   English   中英

無法訪問包含布局內的視圖

[英]Cannot Access Views inside Included layout

我使用的是片段的一部分的“包含”布局。 這是我為包含“ include”的布局充氣的地方(下面是布局本身):

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View v = inflater.inflate(R.layout.hourly_fragment, null);
    return v;
}

hourly_fragment.xml

<include
    android:id="@+id/visualization"
    style="@style/Visualization"
    android:layout_width="match_parent"
    layout="@layout/visualization_with_spinner" />

<include
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    layout="@layout/list_fragment" />


<include
    android:id="@+id/hourly_amazon_details"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    layout="@layout/amazon_details" />

我可以訪問其他2個包含布局中的項目,但不能從“ amazon_details”布局中訪問...。為什么有任何想法?

由於“項目”>“清理”無法解決您的問題,請嘗試將父項設置為“內容視圖”中當前可見的容器:

(正如您在評論回復中發布的那樣:)

inflater.inflate(R.layout.hourly_fragment, container, false);

我是個白痴! 我完全忽略了大版面中的版式,並且正在平板電腦上進行測試。 現在視圖不為空,我只需要弄清楚如何使其顯示在列表下即可。 如果我浪費任何人的時間,我深表歉意。我的糟糕,並感謝您的所有努力!

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM