0

I have a ListFragment Activity in my application, in which, i don´t override the oncreateview. I would like to inflate a View from xml the first time that list is shown. At the moment I am trying to inflate it on the onActivityCreated method, and using:

LayoutInflater layoutInflater = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View view=layoutInflater.inflate(R.layout.my_view,null);

What is the correct approach to do this?

nandeesh
  • 24,740
  • 6
  • 69
  • 79
user1437481
  • 470
  • 1
  • 9
  • 30
  • what's wrong with onCreateView? – Sameer Aug 24 '12 at 09:40
  • you may be interested in my post http://stackoverflow.com/questions/11770773/listfragment-layout-from-xml – sherpya Aug 24 '12 at 09:49
  • currently im not inflating anything in the onCreateView,but when I do try, I have some errrors concerning to things that I have on the onActivityCreated such as setEmptyText, setHasOptionsMenu and getListView – user1437481 Aug 24 '12 at 09:58
  • Fragment lifecycles are a bit tricky. You really should inflate in onCreateView, and then address the other problems. Post your errors and perhaps we can help. – jsmith Aug 24 '12 at 11:22

0 Answers0