Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is any option to add TICK MARK on the right side of the toolbar?

By default android have an option to enable BACK ARROW on the left of the toolbar using

 getSupportActionBar().setDisplayHomeAsUpEnabled(true);
 getSupportActionBar().setDisplayShowHomeEnabled(true);

same like i need TICK MARK on the right of the toolbar, is there any method to enable TICK MARK in android by default.

like image 209
Venkatesh Avatar asked Dec 08 '22 23:12

Venkatesh


1 Answers

First download the "done" icon as png from the materials icon library

Copy the icons to your projects drawable folder.

Then create a file in res/menu called menu_example.xml

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto">
    <item
        android:id="@+id/action_settings"
        android:icon="@drawable/ic_done_white_24dp"
        android:title="@string/action_done"
        app:showAsAction="always" />
</menu>

Then add the following code to your Activity.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
    // Inflate the menu; this adds items to the action bar if it is present.
    getMenuInflater().inflate(R.menu.menu_example, menu);
    return true;
}
like image 103
mach Avatar answered May 28 '23 09:05

mach