menu item home区域的的id

今天真的是手贱啊,明明是android .R.id.home,偏要写成R.id.home

结果半天不出来,点击每反应,做一个备忘:

      

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    // Handle action bar item clicks here. The action bar will
    // automatically handle clicks on the Home/Up button, so long
    // as you specify a parent activity in AndroidManifest.xml.
    int id = item.getItemId();
    //noinspection SimplifiableIfStatement
    switch (id){
        case R.id.action_settings:
            return true;
        case android.R.id.home:
            Intent intent=new Intent(ExploreActivity.this,MainActivity.class);
            startActivity(intent);
            this.finish();
            Log.i(TGA, ":back to main");
            return true;
        default:
            return super.onOptionsItemSelected(item);
    }
}

你可能感兴趣的:(android)