Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 990
isnonety Avatar asked Oct 12 '12 09:10

isnonety


1 Answers

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.

like image 133
Jake Wharton Avatar answered Oct 27 '22 10:10

Jake Wharton