0

In Android application, I have one request that aims to use one common Activity/screen in many screens or in overall of the application.

For example:

  • Screen A contains screen common C (to get better sense, it contains of list of items) ==> during the working on A, C might be modified to have add/modify/remove any items.
  • Now to to Screen B and in turn it contains screen C also. ==> request: C must be the same as one in A and the data is obviously the same.

One more request: it doesn't need to store the list items of C in the DB or in the preference since I thought the loading data phase can reduce the smoothly of the screen B or A at the first time. How's your opinion about this thinking?


Anybody has some ideas about this situation? I'm really appreciate so much.

Thanks, Tri.

Josh Earl
  • 18,151
  • 15
  • 62
  • 91
neojh
  • 27
  • 5

1 Answers1

0

Screens or Activities in Android are independent. You can't nest Activities. I could think of two solutions : a) Save your data as an array List and pass it to B from A when B opens. Since it seems both contain a common layout as part of their own layout, include that layout using <include layout. in your xml for both A and B layouts. b) If you plan to use fragments, make C a fragment and use it in two activites A and B ( could go for better design approaches though when using fragments)

Akhil
  • 13,888
  • 7
  • 35
  • 39
  • yeah, for the nested Activity, I didn't think likes that :) maybe my sentence makes confusing. For the common screen, do you think that we just need a singleton view in overall application. So that when going to Screen B, we just get that instance to embed without re-building again (so we don't need to store list item anymore)? – neojh Mar 28 '12 at 04:56
  • from what I get, you can manage things with a single activity, and make views visible/invisble on your need. It would be better than going to a new activity altogether. – Akhil Mar 28 '12 at 11:19