0

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):

@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" />

I can access the items in the other 2 included layouts, but not from the "amazon_details" layout....any ideas why?

taraloca
  • 9,077
  • 9
  • 44
  • 77
  • Have you tried doing a Project > Clean? I know it's tedious, but I've regularly experienced the same thing and cleaning the project usually solves it. – Cruceo Aug 21 '13 at 20:04
  • cleaned it, restarted it, cleaned it again...still null views when trying to access. Good suggestion. next :) – taraloca Aug 21 '13 at 20:13
  • Does `amazon_details` have `` as its root tag? – Kevin Coppock Aug 21 '13 at 20:21
  • 1
    Hmmm, I thought that would work. I noticed you're passing null as the parent when inflating into; have you maybe tried inflating it into whatever parent your contentView is set to? – Cruceo Aug 21 '13 at 20:27
  • Oh yeah, that's a good catch. Inflating the fragment view from onCreateView() should definitely be `inflater.inflate(R.layout.hourly_fragment, container, false);` – Kevin Coppock Aug 21 '13 at 20:28
  • Nice, glad I could help! Making it an answer for others – Cruceo Aug 21 '13 at 20:29
  • @Cruceo Oh, sorry, I wasn't the OP. :P This may or may not fix his problem. – Kevin Coppock Aug 21 '13 at 20:37
  • Well I'm just an idiot, so we'll see if it works or not. – Cruceo Aug 21 '13 at 20:42

2 Answers2

1

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);
Cruceo
  • 6,763
  • 2
  • 31
  • 52
0

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!

taraloca
  • 9,077
  • 9
  • 44
  • 77