user3132352
user3132352

Reputation: 403

Android change actionbar buttons

I have an application that can make voice recording but I'm stuck with implementing the UI. There is a button in my action bar and when is clicked I want to collapse all I have in the action bar and show the buttons that will be for recording and playing the recorded.

To get the idea: This is my actionbar


     b1 b2 b3 b4

When b3 is clicked:


    play  record

Can you give me an advise how to do that. I'm also interested in other suggestions.

Upvotes: 0

Views: 68

Answers (1)

Tamby Kojak
Tamby Kojak

Reputation: 2159

When a button is pressed, then call Activity.invalidateOptionsMenu()

This will cause onCreateContextMenu() to be called again. Inside that method have some sort of flag that will allow you to determine which menu to inflate.

edit for use of support action bar super.supportInvalidateOptionsMenu();

@Override
public boolean onOptionsItemSelected(MenuItem item) {

    int x = item.getItemId();
    switch (x) {
    case R.id.action_track:
        super.supportInvalidateOptionsMenu();

Upvotes: 1

Related Questions