Same Title bar but different view below it?

by javame_android » Fri, 09 Apr 2010 22:46:25 GMT


Sponsored Links
 Hi,

In one of my Android Application I need to keep the title bar same but
the view that is shown in the rest of the screen changes. So, I have
taken different Activity for all the views that I need to show and set
the title bar in every Activities onCreate method.

Now, the problem is that I have a button in the title bar and need to
perform certain action on its click event. Writing the same event
handling code in every Activity class is very cumbersome. Is there any
other way out that whenever there is a click event on that button of
the title bar then we can have the same functionality without writing
the same code in all the Activity classes.

Can we use ViewGroup for that? I don't have much idea about ViewGroup.
Is that possible with ViewGroup?

If anyone knows the solution then please let me know.

Thanks & Regards
Sunil

--



Same Title bar but different view below it?

by Mark Murphy » Fri, 09 Apr 2010 22:48:31 GMT


 


Step #1: Create a subclass of Activity that includes your button logic

Step #2: Have your other activities subclass the class you created in
step #1

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

_The Busy Coder's Guide to *Advanced* Android Development_
Version 1.4 Available!

--


Sponsored Links


Same Title bar but different view below it?

by javame_android » Fri, 09 Apr 2010 22:58:06 GMT


 Hi,

Thanks for your fast response.

I am just a bit confused by what you said.

Suppose I have a Class A that has my button logic, then according to
what I understood I need to

1. Create a subclass of A such as Class B extends A

2. Other activities subclass B such as Class C extends B

If that's correct then why can't Class C directly extends A such as
Class C extends A

Please correct me if I am wrong.


Thanks & Regards
Sunil

--



Same Title bar but different view below it?

by javame_android » Fri, 09 Apr 2010 23:03:07 GMT


 Hi,

One more thing then when I need to display this subclasses, will they
be displayed as we normally display one activity from another activity
i.e. startActivity(intentObj).

Please reply if anyone knows the solutions.


Thanks & regards
Sunil

--



Same Title bar but different view below it?

by javame_android » Fri, 09 Apr 2010 23:50:54 GMT


 Hi,

I have been able to extend the class and get the button click event in
the same Activity.

But now there is another issue. I want to display images in Gallery
from that button click but its not happening so if I click on that
button from another activity. The onclick method is being called but
its not changing the view to Gallery. If I click on that button from
the main Activity in which there is the button logic then the Gallery
view is being displayed.

Can anyone let me know what is the problem?


Thanks & regards
Sunil

--



Other Threads

1. C2DM - Message to device delivery time

Hi all

Im currently developing a C2DM app, and I`m trying to understand what
controls
the time taken from me requesting a push notification, until the
message is actually sent to my device?

Most of the time I get the message within seconds, but on other
occasions itll take
up to a minute or more before the message is received by my device.
Ive tried on both my HTC Desire and with the emulator, experiencing
the same "issue".

Can anyone please elaborate on this?

Regards
Daniel

-- 

2. Can I use POSIX Message queue in developing platform device driver?

I'm developing EBI driver.
May I use POSIX Message queue in developing this, platform device
driver?
If not, what can I use for alternative.

-- 

3. How to Customise android Os For supporting regional launguages

4. Greystripe banner.refresh causes null pointer exception

5. flash enable browser on eclair

6. Direct interaction between application and library

7. Android Referral Tracking not working