Issue
I used Toolbar component in AppCompat library instead of Default Actionbar.
Compile time: I get compile-error that cannot find symbol android.R.id.home
public void setupActionBar() {
// Set a Toolbar to replace the ActionBar.
toolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
getSupportActionBar().setHomeButtonEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int id = item.getItemId();
if(id == R.id.action_help) {
showHelp();
return true;
}else if(id == android.R.id.home){
Log.d(TAG, "Back Button clicked!");
this.finish();
return true;
}
return super.onOptionsItemSelected(item);
}
Solution
android.R.id.home was introduced in API level 11. here is more detail: https://stackoverflow.com/a/18719090/2178694
Answered By - hr.Astian
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.