Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is TabActivity deprecated (reason)?

This is not a duplicate of How can I use fragments, now that TabActivity is deprecated?

After some research the conclussion is that TabActivity is deprecated because we now have to use fragments. And the reason for that, as far I read, is that fragments work better with the action bar, and with the support compatibility library it's also possible to implement starting at Android 2.1

But I still don't really understand the reason why it's deprecated. Why not just make that the action bar also works with activities? Why are fragments prefered?

I also read fragments have better performance... is that the reason?

Activities at least are cleary separated entities which is something positive. I don't have enough insight in fragments now to understand why they are better.

Thanks in advance...

like image 710
User Avatar asked Oct 07 '22 13:10

User


2 Answers

TabActivity has been deprecated, cause it is subclass of ActivityGroup, which also has been deprecated.

ActityGroup has been deprecated, and instead Fragment has been introduced and suggested. As using Fragments is easier and more flexible than ActivityGroup. It also enable android components to have a homogeneous pattern.

like image 141
jeet Avatar answered Oct 12 '22 11:10

jeet


The main reason for which Google deprecate some methods / objects is to enforce best-practices and get the most homogeneous patterns accross applications.

Marking TabActivities as deprecated will make developpers use the ActionBar system for new applications, but you still can use TabActivities, although it's not encouraged.

Sometimes, They will mark something as deprecated for performance or because the behavior is not up to date with the latest API (for example the Clipboard system, changing from a "text only clipboard" to a "copy and paste anything".

like image 44
XGouchet Avatar answered Oct 12 '22 12:10

XGouchet