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. eclipse keyboard shortcuts: how do you quickly rebuild and run your app after changes?

I find that it's a good idea to have "Build Automatically" checked,
under the Project menu.  That, and I always Ctrl-s (save) each file
pretty often after I make changes to it, and then those changes are
built automatically because that option is turned on.

I have not yet found a way, though, to assign a keyboard command to
launching the app.  But I think you can do this under Window-




-- 

2. help with game development.

hi all,

this to all those who are into game development. i want to start on the game
development in android, and just as a starter, can anyone suggest me an
ebook or a simple procedure oriented blog or some link that'll help me to
get things started!

thanks in advance.




Regards,
Saurav Mukherjee.

-- 

3. Exception when clearing tabs and onResume() from different applications

4. Is it christmas?

5. Android ecommerce and processing credit cards

6. App Not showing up on Verizon DROID Phones

7. ActivityManager.restartPackage() is not working