3

I am going to create an Android application that supports multiple API levels. I searched the Android Developers website and learned that this is done as follows:

if (android.os.Build.VERSION.SDK_INT >= 11) 
{
  // Use APIs supported by API level 11 (Android 3.0) and up
} 
else 
{
  // Do something different to support older versions
}

The above is used in Java files, but what about XML files? I am using some Android 4.0 tags.

I am an iOS developer, too. In iOS, I always design UIs programmetically. Which is better in Android applications: creating applications programmatically, like I do for iOS applications, or by using XML files.

Android UI design is not good like iOS UI design is.

2
  • Well I have tried this, obviously it will not working, if the class you used not in current SDK, will give your errors. You can check "/SDK/extras/android/support", there is an jar library to use some features on android 3.0+ in your android 1.6+ project. Commented Sep 13, 2012 at 12:27
  • 1
    Android UI design is not good like iOS UI design good is very general, sure things can be wrong with it and they both use different technologies to do the same thing. Try to explain why next time! Commented Sep 26, 2012 at 17:49

2 Answers 2

7

You can have different subfolders in your res directory such as layout-v11, layout-v14 in addition to your layout folder. then if you are running, say, API 14, your app will frist try taking needed xml files from layout-v14, only then from layout directory. The same applies to other folders under the res directory.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks , I think you are right . But my Question is How my app takes the Layout-v14 . Is there any coding for that ?.
@user1667746 No, no coding for that. You just should have, say, main.xml under layout and main.xml under layout-v14. Then, if you are indeed running API14 the main xml from layout-v14 will be used, otherwise from layout. You can try that on the emulator with different AVDs
0

You could try the support android library http://developer.android.com/tools/extras/support-library.html that lets you implement many classes in older SDKs or the ActionBarSherlock that lets you implement action bar in devices with API LEVEL < 11 and comes with a lot of examples with Fragments.

1 Comment

ok thanks . which is better in android application whether creating an application programmatic like ios application or by using xml file.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.