I am planning to convert the activities in my app to fragments to implement a drawer. But I have never used fragments before and they seem kinda complicated, so I'm asking for some quick help:
What are the basic "rules" to convert from activity to fragment?
All I have so far is that
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
becomes
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
return inflater.inflate(R.layout.activity_main, container, false);
What else? I guess I also have to change each layout from Linear/Relative to Fragment.
EDIT I can't seem to figure it out properly. I have 3 activities:
A - base activity, no layout, starts service, threads, does a lot. Most back-end
B - extends A, has a layout. It's the main startup activity. Most front-end
C - extends A, has a layout. It's started via button from B.
Any suggestions on which and how to turn them to fragments?