[英]Cannot Access Views inside Included layout
I am using an "include" layout that is part of a fragment. 我使用的是片段的一部分的“包含”布局。 Here is where I inflate the layout that includes the "include" (and below it is the layout itself):
这是我为包含“ 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 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" />
I can access the items in the other 2 included layouts, but not from the "amazon_details" layout....any ideas why? 我可以访问其他2个包含布局中的项目,但不能从“ amazon_details”布局中访问...。为什么有任何想法?
Since a Project > Clean did not solve your problem, try setting the parent to the container currently visible in your Content View: 由于“项目”>“清理”无法解决您的问题,请尝试将父项设置为“内容视图”中当前可见的容器:
(As you posted in your comment response:) (正如您在评论回复中发布的那样:)
inflater.inflate(R.layout.hourly_fragment, container, false);
I'm an idiot! 我是个白痴! I totally overlooked a layout in the layout-large and I am testing on a tablet.
我完全忽略了大版面中的版式,并且正在平板电脑上进行测试。 Now the views are not null, I just have to figure how to get it to show under the list.
现在视图不为空,我只需要弄清楚如何使其显示在列表下即可。 I apologize if I wasted anyone's time...my bad and thanks for all the efforts!
如果我浪费任何人的时间,我深表歉意。我的糟糕,并感谢您的所有努力!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.