Compiling Error With Api 10
Solution 1:
First, you're going to want to make sure that you are compiling against the latest version of Android. You should update your sdk version because you're compiling for API 10 but targeting 16. Stuff may break if you do that, so it's best to stay updated to be safe.
This means right clicking on your project in Eclipse, clicking on Properties then clicking on Android. Check off the highest version API that is there. If you have the latest version, it is Android 4.2. Then in your AndroidManifest.xml, set the android:targetSdkVersion
to what you chose (my case api 17).
This should ensure that your app can run on basically HoneyComb to JellyBean. However, this app wants to run on at least froyo. This next part will allow your app to run on all devices.
Make a method like this:
@TargetApi(Build.VERSION_CODES.HONEYCOMB)privatevoidsetupActionBar() {
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
// Show the Up button in the action bar.
getActionBar().setDisplayHomeAsUpEnabled(true);
}
}
It checks to see which API it is running on and only if it is honeycomb and above, enables the action bar.
Call it from onCreate()
You will need to take out the getActionBarCall that is in onCreate()
as it is not needed anymore there.
As for home not being enabled, it might have just been a wrong project target or you forgot to write android.R.id.home
and instead wrote R.id.home
.
Lastly with all these changes you should clean your project (Project -> Clean).
Solution 2:
Check out this http://actionbarsherlock.com/, it will let you user actionbar in low api level.
Post a Comment for "Compiling Error With Api 10"