Have you looked into TabWidget ?? I guess you should be using that.
Thanks and Regards, Kumar Bibek http://tech-droid.blogspot.com On Dec 22, 10:29 am, Samuh <[email protected]> wrote: > I have a requirement to create a control similar to UITabBar in > iPhone, which is to be present on every activity of my application. > UITabBar essentially is a battery of buttons exhibiting a TAB like > behavior: every button maps to an activity. > I have two solutions for this: > 1. In the layout XML for every activity, I insert a > <LinearLayout><Button/><Button/><Button/></LinearLayout> element. And > then have a common listener class that will handle the button clicks. > So, every activity will have an instance of this listener. > 2. To create a custom Widget extending LinearLayout class, put all the > buttons as its static members and let it handle the button clicks. > Include this custom control in every screen. > > Following is what I think about this: > The problem with first approach: > 1. it will generate a lot of boiler plate code(findViewByIds, > setOnClickListener etc.) > 2. Assuming that there are 5 activities and 3 tab buttons, total > number of Button objects created at Runtime will be 5 x 3 = 15 > > I'd like to take the 2nd approach because: > 1. All the code(state and behavior) will be encapsulated by the widget > class. Less Boilerplate code. > 2. Since, the buttons will be static members, the total number of > Button objects created at Runtime will be only three. Though, the > static members will remain in memory for a longer time(until JVM > unloads the class), since the control is present on every screen I > think this can be excused. > > I am not sure which approach to follow. Please advice. Alternatives > also appreciated. > > Thanks. -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en

