johannilsson / android-actionbar

DEPRECATED Android Action Bar Implementation
1.31k stars 564 forks source link

Clear actionbar #16

Closed obra closed 13 years ago

obra commented 13 years ago

I find myself needing to change the items in the actionbar at runtime. Since we don't yet have a way to name actionbar items and access them by id, I believe my best option is to reset the displayed actions and go from there.

This commit adds an API to do just that.

johannilsson commented 13 years ago

Great idea, thank you.

Yes it would be more convenient to be able to set id or a tag on a action. I'm currently thinking of changing the Action into something like the Tab that came with the ActionBar in Honeycomb.

I've added three new methods (inspired by your commit), getActionCount, removeActionAt and removeAction. removeAction tries to find a matching action to remove, this might work or might not work. Please let me know what you think if you find the time.

https://github.com/johannilsson/android-actionbar/commit/aed73df8edc626995b0a811b618539b2010def34

obra commented 13 years ago

The new methods make sense. I'd be a little nervous about removeAction being to DWIMMY without being able to give the actions names/ids.

Maybe instead have a getActionAt() method that lets you load up a particular action by index and force the user to do the comparison manually?

I'd be totally in favor of revamped functionality to make ActionBar more like honeycomb's. Somebody has to build an API compatible version of what Google's shipping in H, though it doesn't look like it'll be easy.

On the upside, we should have Honeycomb source to crib from in a few days.

johannilsson commented 13 years ago

Makes sense to have a getActionAt. Guess it would work to implement your own action with ids with it's own equal method to check on, not totally sure though. And I'm happy to remove the removeAction if it turns out that it's not reliable.

But I think we should try to find the lowest common denominator between this action bar and the one in H instead of porting the whole functionality, at least as a start. I will be away from my computer for a few days so I can't start working on this right away. I will read emails and pull requests if anyone finds the time though.