Derived Activity / Access Views / Notifications

Put your problem here if it does not fit any of the other categories.

Derived Activity / Access Views / Notifications

Postby chris_abyi » Fri Feb 25, 2011 3:26 pm

Hi,

I got a problem since several days now and tried out almost everything. I'd really appreciate any help:

I'm implementing a small mp3-player to get into Android development. This player supplies the user with two different playback screens (different layouts etc.). Hence, I developed a class called PlaybackActivity which provides all necessary methods for music playback and retrieving metadata and 2 other classes, one for each playback mode. Those classes inherit from PlaybackActivity and define their layout in their own onCreate-Method.

So far, so good. Everything, also the playback, works fine. But: When one track finishes (in the PlaybackActivity), there's a need to set the view elements of its child class to the new metadata. Unfortunately, I've got no idea how-to do so.

One of the things I tried: Declaring PlaybackActivity as abstract class with a method "setMetadata()", then implementing this method in its child classes. Then I call this method in the parent class and in eclipse debug, it correctly jumps into the implemented version of its child class. There, I tried to retrieve the views by findViewById - but: they're null! When I do a setContentView(Layout) before, they're initialised, but I don't see any changes in the output. It's as if I'm dealing with 2 activities, but I don't know why.

Thank you very much for your ideas!
Chris
chris_abyi
Freshman
Freshman
 
Posts: 3
Joined: Fri Feb 25, 2011 3:19 pm

Top

Re: Derived Activity / Access Views / Notifications

Postby blundell » Sat Feb 26, 2011 12:48 pm

You need to setContentView in the child activity.
User avatar
blundell
Master Developer
Master Developer
 
Posts: 1610
Joined: Tue Nov 18, 2008 12:58 pm
Location: UK

Top

Return to Other Coding-Problems

Who is online

Users browsing this forum: No registered users and 19 guests