[android] Display Back Arrow on Toolbar

This worked perfectly

public class BackButton extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.chat_box);
        Toolbar chatbox_toolbar=(Toolbar)findViewById(R.id.chat_box_toolbar);
        chatbox_toolbar.setTitle("Demo Back Button");
        chatbox_toolbar.setTitleTextColor(getResources().getColor(R.color.white));
        setSupportActionBar(chatbox_toolbar);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
        chatbox_toolbar.setNavigationOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                //Define Back Button Function
            }
        });
    }
}

Examples related to android

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? How to implement a simple scenario the OO way My eclipse won't open, i download the bundle pack it keeps saying error log getting " (1) no such column: _id10 " error java doesn't run if structure inside of onclick listener Cannot retrieve string(s) from preferences (settings) strange error in my Animation Drawable how to put image in a bundle and pass it to another activity FragmentActivity to Fragment A failure occurred while executing com.android.build.gradle.internal.tasks

Examples related to android-actionbar

Under what circumstances can I call findViewById with an Options Menu / Action Bar item? Failed to load AppCompat ActionBar with unknown error in android studio Android transparent status bar and actionbar ActionBarActivity is deprecated Manage toolbar's navigation and back button from fragment in android setSupportActionBar toolbar cannot be applied to (android.widget.Toolbar) error How to use SearchView in Toolbar Android How to get Toolbar from fragment? Display Back Arrow on Toolbar Remove title in Toolbar in appcompat-v7

Examples related to android-actionbar-compat

Android: remove left margin from actionbar's custom layout Display Back Arrow on Toolbar Change Toolbar color in Appcompat 21 Toolbar navigation icon never set No resource found - Theme.AppCompat.Light.DarkActionBar getSupportActionBar() The method getSupportActionBar() is undefined for the type TaskActivity. Why? Can't Find Theme.AppCompat.Light for New Android ActionBar Support

Examples related to android-toolbar

Add views below toolbar in CoordinatorLayout Creating a button in Android Toolbar Android transparent status bar and actionbar Manage toolbar's navigation and back button from fragment in android How to change Toolbar Navigation and Overflow Menu icons (appcompat v7)? Toolbar Navigation Hamburger Icon missing How to use SearchView in Toolbar Android How to get Toolbar from fragment? How to add buttons like refresh and search in ToolBar in Android? Change status bar color with AppCompat ActionBarActivity