Should a newbie forget about fragments? - android

I just started developing on Android. I'm practicing with a Tablayout tutorial in API 15 when I see TabActivities are deprecated.
Would I be better off just forgetting about Fragments for now and keep developing with TabActivities?

Would I be better off just forgetting about Fragments for now and keep developing with TabActivities?
IMHO, no.
Get yourself a copy of ActionBarSherlock and implement tabs in the action bar. That is the tab pattern going forward with Honeycomb and Ice Cream Sandwich, and ActionBarSherlock lets you use the same approach for Android 2.x devices as well. You are better served aiming for the future, not the past.
Note that you do not have to use fragments with action bar tabs, though you can.

I suggest you learn Fragments. There's no point in using TabActivities any more, there's a static support libary (you can see it available for download in Android SDK Manager) that will allow you to use fragments on older APIs - that's the way it's meant to be done now.
Go with Fragments and action bar pattern, new is always better :)
Also, be ready to dump any other deprecated piece of API or obsolete UI approach. Mobile development evolves pretty quickly.

No, just follow the example here for how to Tabs with Fragments: http://developer.android.com/reference/android/app/TabActivity.html

Normally, I would say that using a deprecated API is a bad idea. However, since you are just practicing and presumably do not need to release this application on a wide range of devices, then just carry on with the tutorial and happy learning.
Hope that helps and enjoy Android.

Related

Tabs layout and Android sdk

Until now I was using TabActivity for Tabs layout.
Since this Activity is deprecated What will be the best way to form a tabs interface?
I saw many tutorials showing the use of TabFragments but this is good only for high sdk version (15 and higher).
So what objects can I use for tabs layout considering it should work with API 10 and above and of course not deprecated?
An example will be great!
As Commonsware said here ::
"Deprecated" in Android means "we think there is a better solution that you should investigate". Rarely does "deprecated" mean "it is unusable". TabHost, AFAIK, works fine on Android 4.0.
There are also project named ActionBarSherlock which demos have all the capability of the compatibility library. Source code is also available on github.
There is also this tutorial which helps you how to use TabFragement.
I faced the same question while ago too and the best solution is use ActionBarSherlock with Fragments and there is a really nice tutorial how to implement TabHost in your app which you can find here :
ActionBarSherlock:FragmentTabs.
It worked for me, hope it will work for you too : )
P.S. And one another thing, it is really good when you are building an application to look for design guidelines and the best ways you can build your app so you can take advantage of the latest news in Android App Development.

Scrolling in widgets in Android 2.x with android-support-v4.jar?

As I can see, more and more functions from Android 4.x like fragments or action bar are now supported on lower android versions by using support library. Anyone knows, if it works also for scrolling inside widget, which was introduced in Android 3.x? thx
Probably not going to happen, and probably not really possible. This needs support for the corresponding RemoteView's, etc. which is a little deeper in the platform than fragments, etc. You are, of course, welcome to give it a try.

Cross Version Compatible Android Tabbed Layout

I'm looking to create a cross-version compatible android tabbed layout.
The problem I'm running into is when implementing Google's example of TabActivity, I get a depreciation notice. The app I'm writing needs to be compatible down to 2.1, and I'm not finding a clear cut way to make it compatible.
I am aware of the versioning by folder (/layout-v4, /layout-v14, etc) but if possible I want to avoid this.
Are fragments the answer here and if so, does the Android Compatibility Layer V4 become the key to solving this problem?
I'd suggest the best approach might be to use the excellent (and free) ActionBarSherlock, so you can add Android 3+ action bar (including tabs) to apps going all the way back to v2.x versions.
I've used it on a few apps and it's pretty easy. I think it's the right approach to use the proper Action Bar interface across platform versions, and they include tabs and replace the whole TabActivity thing, which was pretty horrible anyway.
http://actionbarsherlock.com/

Is it ok to use TabActivity still for my app?

My app is in need of some tabs and the TabActivity works great for it. It's much easier than wrapping my head around those Fragments... but I see that Android says to do Tabs in FragmentActivity now... My question is If I'm targetting 2.2 phones is it ok for me to use the TabActivity instead? Will I run into any issues in the future by making the app this way?
Its recommended to use Fragments, i know it has an initial learning of few hours but its worth the effort. Use compatibility library for using fragments in Android versions lower than 11.

On Android's Support Package, use it or not?

I've been thinking about the pros and cons of using Android's Support Package when targeting the latest API and setting the min SDK to 7, for example.
The Android documentation states "The goal is to simplify your development by offering more APIs that you can bundle with your application so you can worry less about platform versions"; however, I'm having some doubt on whether it will make it simpler.
Consider the TabActivity, which has been deprecated. The alternative to using TabActivity is through Fragments and by looking at the example to get a tabular view working, it doesn't look simpler. Besides, I have to use reflection anyways when deciding on to use the Fragments class versus the FragmentActivity class, so why not just use TabActivity. I was hoping to get your opinion on this. I'm leaning towards not using it, but I would like to know if I'm missing out on any benefits.
The alternative to using TabActivity is through Fragments
An alternative to using TabActivity is through Fragments, using the icky stuff in the example you cite. The better alternative to using TabActivity is to put your tabs in the action bar, perhaps using ActionBarSherlock's fork of the Android support library that offers a backwards-compatible action bar.
by looking at the example to get a tabular view working, it doesn't look simpler
It's not.
Besides, I have to use reflection anyways when deciding on to use the Fragments class versus the FragmentActivity class
If you are using the Android support library, you should not need this, as you always extend FragmentActivity.
I'm leaning towards not using it, but I would like to know if I'm missing out on any benefits.
If you plan on supporting tablets and/or TVs, you want to be using fragments. Fragments are useful even in phone-only apps, but not quite as visibly.

Categories

Resources