-4

I want to put a check mark on my action bar instead of the 3 dots menu. The activity will then be finished after the check is clicked. How can I achieve this?

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Steven
  • 13
  • 3

2 Answers2

0

You can achieve this by adding your own menu in your activity/fragment.

and after adding all that use something like this

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    switch (item.getItemId()) {
        case R.id.tick:
            finish();
            break;
    }
    return true;
}
Ankit Aman
  • 999
  • 6
  • 15
0

Create a new folder under res folder named menu. Right click it and add a new menu resource, name it something like mymenu.xml. Add this code:

<item
    android:title="check"
    android:id="@+id/check"
    android:icon="@android:drawable/ic_dialog_info"
    android:orderInCategory="100"
    app:showAsAction="always"/>

You can change the icon to any other. Handle it in onOptionsItemSelected (like in above reply).

Sanjeev
  • 141
  • 2