Search code examples
androidactionbarsherlock

ActionBarsherlock android.R.id.home <API 11


When i used Actionbarsherlock

public boolean onOptionsItemSelected(MenuItem item)
{
    switch (item.getItemId())
    {
    case android.R.id.home:
        this.finish();
        return true;
    default:
        return super.onOptionsItemSelected(item);
    }
}

I notice that android.R.id.home is from API 11. How can we make sure android.R.id.home is right on API 8?


Solution

  • It is a static final constant which means its value is copied into the compiled code instead of being just a reference. This is why it is able to be used successfully on every API level.