开发者

Navbar Class in all activities

Ok, I am doing something. I have a navigation bar that contains all the buttons for my activities. I have tried the method of Extending the other activities to the "navbar" class.

Here is what I have done so far:

  • I have extended all the classes to navbar (Except those that will need multiple inheritance).
  • used an tag in every XML layout.

What I need:

  • I need classes to handle multiple inheritance
  • All my classes even those that do not need multiple inheritance, to extend my navbar class.

If multipl开发者_运维问答e inheritance is not possible, I do not mind hardcoding those classes, but multiple inheritance would be very nice :)

thanks in advance.


Java does not support multiple inheritance, sorry.

Rather than roll your own "navbar", you might consider using the action bar on Honeycomb, perhaps then using ActionBarSherlock to support pre-Honeycomb devices from the same code base.


You could do what I did for my app.

Create a "base" activity that all other activities extend.

Fill your menu bar and set up all of the listeners with Intents in it, then allow each activity to handle everything else.

The other option would be to create a XML element with whatever you want in it (if it needs to be more complex than a menu for some reason). You should still use the "base" activity idea for this.

Hope this helps.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜