8
I'm just starting to do Android development, more-or-less following the http://developer.android.com/training/basics/firstapp/starting-activity.html tutorial, and one thing keeps bugging me: I have two classes, both created using the "Android Activity" creation wizard:
public class PlacesActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_places);
// I manually commented out the following line to get it to compile.
// getActionBar().setDisplayHomeAsUpEnabled(true);
}
// ... other methods
}
and
public class ShowOnePlace extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_show_one_place);
getActionBar().setDisplayHomeAsUpEnabled(true);
}
// ... other methods
}
Eclipse kept giving me the following errors:
Call requires API level 11 (current min is 8): android.app.Activity#getActionBar
Call requires API level 11 (current min is 8): android.app.ActionBar#setDisplayHomeAsUpEnabled
until I commented out one of the lines (as shown above). Now the application seems to compile and run on my Android device without errors. (Well, at least without that error).
So:
- Why is
getActionBar().setDisplayHomeAsUpEnabled(true);give that error in one class, but that exact same line is not an error -- not even a warning -- in the other class? - Is there a bug in the "Android Activity" creation wizard, and somehow that
getActionBar().setDisplayHomeAsUpEnabled(true);statement is wrong in o