Use Hierarchy View to examine your activity and see what is and is not actually there.
On Sat, Sep 1, 2012 at 3:24 PM, dminik <[email protected]> wrote: > Hello! > > I'm a newbie in software development for android. In my simple program I'm > trying to add a new fragment into the main activity during run-time. And > here is the place where problems come - the fragment doesn't appear at all. > Here is the code from the main activity: > > public class MainActivity extends FragmentActivity { > > @Override > public void onCreate(Bundle savedInstanceState) { > super.onCreate(savedInstanceState); > setContentView(R.layout.container_calendar); > > if(this.findViewById(R.layout.container_calendar) != null) > { > if(savedInstanceState != null) > { > return; > } > > CalendarFragment calendar = new CalendarFragment(); > calendar.setArguments(getIntent().getExtras()); > > FragmentTransaction transaction = > this.getSupportFragmentManager().beginTransaction(); > transaction.add(R.id.calendar_container, calendar); > transaction.commit(); > } > } > } > > And here is a fragment's code: > > public class CalendarFragment extends Fragment { > @Override > public View onCreateView(LayoutInflater inflater, ViewGroup container, > Bundle savedInstanceState) > { > return inflater.inflate(R.layout.calendar_layout, container, false); > } > > } > > So, as you can see, everything is simple and according to the manuals > suppose to work just fine. But something is going wrong. The fragment > container exists. > > What's wrong with code? Why fragment doesn't appear onto the main activity? > > Thanks in advance! > > > -- > 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 -- Mark Murphy (a Commons Guy) http://commonsware.com | http://github.com/commonsguy http://commonsware.com/blog | http://twitter.com/commonsguy _The Busy Coder's Guide to Android Development_ Version 4.1 Available! -- 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

