2

I've recently decided to update my app to support the new fragments feature in honeycomb 3.0. My Application currently works on a list view that opens different activities depending on which list item is clicked. Using an adaptation of the code in this tutorial I have created an app that consists of only two activities, but depending on which list item is clicked the second "viewer" activity launches using a different layout xml.

Unfortunately I haven't been able to figure out how to call the old methods that had all the functionality. Should I Import all of my old activities and then call the methods into the viewer activity (I may need some advice on how exactly to do this) or should I just put all the methods directly into the same viewer activity (please consider the size of these methods(which is very large by the way)).

Once everything is working with two activities upfront then it will be a pretty simple task of "fragmenting" the app as demonstrated here Although I haven't considered that there might be a way to allow multiple fragments to occupy the same space in an activity(If this is the case then please let me know how it's done)

Thanks

Programmer Bruce
  • 64,977
  • 7
  • 99
  • 97
Jack
  • 2,625
  • 5
  • 33
  • 56

2 Answers2

1

As James has pointed out you will have to move the business logic from your Activities to your Fragments. To handle events you can create a listener Interface. The CONTAINER activity/ies will implement this interface. As fragments has access to the container activity you will be able to delegate to the container Activity the "logic" for the desired events. For this events the activity will decide whether to launch a new activity, show/hide new fragments or whatever.

I had a similar question, take a look to the question and answer: here

Although I haven't considered that there might be a way to allow multiple fragments to occupy the same space in an activity(If this is the case then please let me know how it's done)

I think its possible to allow multiple fragments to occupy the same space in an activity. Again, take a look to the answer here ... I think the concept/scope of Activity has change a bit and now an Activity can contain different Fragments which every one will allow user to do a single focused thing.

Community
  • 1
  • 1
Axel M. Garcia
  • 5,138
  • 9
  • 27
  • 29
0

I'm not sure what you mean by "call the old methods that had all the functionality". You'll want to rewrite all of your activity classes as fragments. Check out this tutorial here (it's very concise). Basically, you'll want an activity that consists of a ListFragment and a FrameLayout. Your ListFragment will update the FrameLayout by changing to the appropriate Fragment based on which row was selected.

James
  • 2,346
  • 1
  • 16
  • 18
  • What I meant by holding functionality was that my old activities had onClickHandlers so when the button was clicked a calculation occurred. ATM I have managed to get the layouts to show but I am having trouble reimplementing the ClickHandlers. I was wondering I you knew a good way to go about this. – Jack Apr 12 '11 at 21:05
  • Can you be more specific about the trouble you're having? – James Apr 12 '11 at 23:55