Add return arrow
//OnCreate methodActionBar actionBar = (); ("Search Function"); (true); // Methods in activity class@Override public boolean onOptionsItemSelected(MenuItem item) { if(() == ) { finish(); return true; } return (item); }
Here, ActionBar introduces package: import .;
2. ToolBar adds return arrow
The code is as follows:
// in onCreate functionToolbar mToolbarTb = (Toolbar) findViewById(); setSupportActionBar(mToolbarTb); getSupportActionBar().setDisplayHomeAsUpEnabled(true); // Methods in activity class//Add click to return arrow event@Override public boolean onOptionsItemSelected(MenuItem item) { if(() == ) { finish(); return true; } return (item); }
Summarize
The above is the example code for adding return arrows to ActionBar and ToolBar in Android introduced to you. I hope it will be helpful to you. If you have any questions, please leave me a message and the editor will reply to you in time. Thank you very much for your support for my website!