I'm using the v4 support package to get Fragment support in older
devices. I've got a fragment that I would like to include in an
Activity, and I've done the following:
1. Added the fragment to the Activity's XML layout via a <fragment>
tag.
2. Added a layout for the fragment in my res/layouts/ folder.
3. Added some Java code for my fragment (included below)
#1 and #2 appear to be working, but #3 gives me an error when I try to
call getView():
public class MyFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup
container,
Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.awesome_layout, container,
false);
return view;
}
public void update() {
TextView name = (TextView) getView().findViewById(R.id.nameView);
name.setText("An awesome name!");
}
}
Specifically, I get back an
"android.support.v4.app.NoSaveStateFrameLayout" object from getView(),
when I'm expecting the view I inflated to be returned (or at least
null to tell me I messed up). I call the update() method in my
Activity's onCreate() method, after calling setContentLayout(). I've
also tried calling update() well after my Activity has been created
and hanging around for a while, but I get the same behavior.
Does anyone have any pointers as to why I might be getting a different
object back from getView()?
Thanks,
Randy
--
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en