1

I have a tabHost, with to tabs and an activity each one of them.

In the tabHost i also have a menu, with the save action. when i press the save in the menu,

i must get all the stuff that are inside those activities, like EditText text value content, checkbox checked value. Im running throw google and i only find how to setup the tabs.. but i cant find how to do what i've describe above.

I have tried usind the findViewById passing the EditText or the CheckBox that are on those activities.. the result was null..

Any thougths?

Thanks in advance.

codemonkeybr
  • 115
  • 7
  • 1
    Check this out... This is the same thing you are asking: http://stackoverflow.com/questions/5319648/android-how-to-call-function-of-activity-inside-of-tab-from-the-tabhost – Anthony Graglia Aug 11 '11 at 12:55
  • It wont let me know post the link as an answer but that is basically a duplicate and should have the answer. – Anthony Graglia Aug 11 '11 at 12:57
  • @trgraglia thats not the samething, i saw that one.. calls the function in the activity, i just want to get the content from it to get its value. maybe do something to be able to make the findviewbyid to work, of something that just give me the value of the contents inside de view. But thanks anyway. – codemonkeybr Aug 11 '11 at 13:14
  • 1
    Just have a function in each activity and run them with that data. Or have listeners for text changes which write to shared preferences or something of that sort which then the tab host can see. – Anthony Graglia Aug 11 '11 at 13:50
  • oh, i see... well ill try that, i thought i should be an cleaner way to do it.. but that will do. Thanks – codemonkeybr Aug 11 '11 at 14:39
  • The cleanest would be the way in that link and a function in the activity but if you need info from multiple tabs, it may be easier with shared preferences. Feel free to accept if it works for you. – Anthony Graglia Aug 11 '11 at 15:55

1 Answers1

1

The link above is one solution. I will repeat it here for everyone. You can then call functions in each tab's activity which writes the data.

Another option is to write to shared preferences on text change for the edit text widgets and then get that information for the tab host.

Link: Android: How to call function of Activity inside of tab from the tabhost

Community
  • 1
  • 1
Anthony Graglia
  • 5,355
  • 5
  • 46
  • 75