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.
Related
I am getting this exception in the designer:
Exception raised during rendering: No tab known for tag null
I have the same EXACT code as this guy -
Android FragmentTabHost : No tab known for tag null
his only answer was "use an older deprecated class" - TabHost instead of FragmentTabHost which is the one that I understood you need to use instead of...
I am a beginner to Android and to Java, but i've been a programmer for many years in .NET, and i find it really hard to find good solutions to very basic problems that came from apparently the only 3 tutorials for fragments out there (just like the one stated above)
So basically here are my questions so far:
From what i understood so far, the only way to actually make a menu to your Android application is to make it a single Activity app with fragments, if this is true, how should i keep track of my fragments if FragmentTagHost is not fully working yet? I found references for ActionBarSherlock - his latest version is using a lot of deprecated classes too
What are the best practices with using a single activity + fragments, and where can i find good helpful examples to get me going to achieve the ui i want to make?
Are there other third party solutions that can help along like ActionBarSherlock?
I am using the Eclipse ADT, would you recommend a different IDE?
Thanks a lot
PS - please don't refer me to the android developer tutorials, i've been thru them, and they are like learning the abc's while i need to make sentences and trying to find good sources for that, i am saying that because i found plenty of good questions on here that were just answered with "here is the really basic tutorial, go do that"
Find AndroidApiDemos project in the samples folder of SDK http://developer.android.com/tools/samples/index.html
There you can find FragmentTabs demo which is what you need, i assume
As for 3. Yes, there are a lot of different solutions. Previously in PlayStore was a good app with different UI patterns and links to the opensource projects implementing them com.groidify.uipatterns. Hope you can find it via google somewhere such as now it is not available
I am going to make my first app for android (no fear it's just a school project and won't be another useless app in the market :>).
So, before starting this task I did some tutorials, one of these (and which I thought would be very useful, because of the sqlite part) was the Notepad Tutorial. While working through it I saw it was originally designed for Android 1.8 or something (certainly it still worked on my android 4.1).
What I'm really wondering now is:
Is this code still "state of the art" in android programming (especially sqlite, but also the rest :) or is it "deprecated"? If so, can you point me to something newer and better?
Thank you.
SQLite is definitely still the database available by default on every Android device. Also, the basics covered in this tutorial still apply to any Android version. Of course, every new version of the OS also provides new possibilities as to which controls you can use or other new APIs, but for very simple applications, this tutorial is still valid.
I skimmed the article; most of its content seem to be valid for Android 4.x.
Although I don't think the tutorial mention fragments anywhere : they were introduced with Android 3.0.
I think that an important exercise after this tutorial is to read the fragment documentation; have a look at some samples (like the gallery app) and rewrite the notepad in order to use fragments.
You will have to use the Support Library in order to use fragments if the minimum version of Android supported by your app is inferior to Android 3.0 but I think it is also an interesting exercise.
A little tip : many beginners (and experienced devs also :) ) mistakes come from adding a new element in an app but forgetting to declare it in the manifest.xml.
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/
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.
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.