Existing activity on fragments

I created tab fragments in android 2.2 , with android compatibility support library , now I have few actions in my application, some of them extend the Activity class, and some of them extend ListActivity.

so how can I convert an existing Activity or ListActivity into Fragments so that I can take advantage of the Fragment functions?

As for creating a fragment, you need to extend the Fragment class, but if ListActivity is activated as a result, what should I do to convert it to a fragment?

+6
source share
2 answers

You need to view the documentation and Fragment samples on the Android Developers website. This will explain what the Fragment can do, and what you should do inside your fragment.

In fact, this is a very simple transition to using fragments when you look at examples. You will need an Activity to contain fragments.

To make this much easier, I would advise you to look into the ActionBarSherlock library, which will allow you to use ActionBar and SupportLibrary back to 2.1.

To get started, you'll want to use the Fragment and ListFragment , which will be very similar to standard activity, but the life cycles are slightly different from a few name changes.

+4
source

You can try to extract it from ListFragment

+2
source

Source: https://habr.com/ru/post/911095/


All Articles