How to update data in Fragment UI?
<p>I have the following class extended Fragment:</p>

<pre><code>public static class DummySectionFragment extends Fragment {

    public static final String ARG_SECTION_NUMBER = "section_number";
    private GridView events;

    public DummySectionFragment() {}

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
            Bundle savedInstanceState) {
        Bundle args = getArguments();
        switch (args.getInt(ARG_SECTION_NUMBER)) {
            case 1 : return initializeCalendarScreen(inflater);
            case 2 : return inflater.inflate(R.layout.todo_lists_layout, null);
        }         
        return null;           
    }

    public void updateGridView() {

        int daysInCurrentMonth=(MainActivity.month==1) ? daysInFebruary : COUNT_OF_DAYS_IN_MONTH[MainActivity.month];
        int daysInPrevMonth=(MainActivity.month-1==1) ? daysInFebruary : COUNT_OF_DAYS_IN_MONTH[MainActivity.month-1];
        int daysInNextMonth=(MainActivity.month+1==1) ? daysInFebruary : COUNT_OF_DAYS_IN_MONTH[MainActivity.month+1];

        Calendar calendar=Calendar.getInstance();
        calendar.set(MainActivity.year, MainActivity.month, 1);
        int startDayOfWeek=calendar.get(Calendar.DAY_OF_WEEK);
        List&lt;Integer&gt; dates=new ArrayList&lt;Integer&gt;();
        for (int i=0; i&lt;startDayOfWeek-1; i++) {
            dates.add(daysInPrevMonth-i);
        }
        for (int i=0; i&lt;daysInCurrentMonth; i++) {
            dates.add(i+1);
        }

        ArrayAdapter&lt;Integer&gt; adapter=new ArrayAdapter&lt;Integer&gt;(getActivity(), R.layout.grid_view_cell_layout, R.id.textViewGridCell, dates);
        events.setAdapter(adapter);
    }

    private View initializeCalendarScreen(LayoutInflater inflater) {
        View layout=inflater.inflate(R.layout.calendar_layout, null);
        events=(GridView)layout.findViewById(R.id.gridViewCalendar);
        updateGridView();
        return layout;
    }
}
</code></pre>

<p>It works good (I use it for FragmentPagerAdapter). And I use method updateGridView() from Activity for updating value in GridView. But if I do it I will got NullPointerException, because getActivity() for ArrayAdapter returns null. Please, tell me, how can I update Fragment UI from Activity? Thank you</p>
