I set basic tab activity similar to that of Google's tab tutorial. However, above TabWidget I have a text view that I would like to update and change the text after some events in each child tab / child activity (not necessarily switching between tabs). I know that I can not be able to force the incidents between activities, so why is there any idea about how to achieve it? Set up a service that communicates via both tabactivity and child activities? Is child activity active, while it is possible to retrieve TextView in TabHost here?
My tab activity wins the following scene:
& lt; TabHost xmlns: Android = "http://schemas.android.com/apk/res/android" Android: Id = "@ android: id / tabhost" Android: layout_width = "fill_parent" Android: layout_height = "fill_parent" & gt; ; & Lt; LinearLayout Android: orientation = "vertical" android: layout_width = "fill_parent" android: layout_height = "fill_parent" & gt; & Lt; TextView Android: Android: Android: Android: "Some text to update" Android: Android: Android: layout_height = "wrap_ content" & gt; & Lt; / TextView & gt; & Lt; TabWidget android: id = "@ android: id / tab" android: layout_width = "fill_parent" android: layout_height = "wrap_content" /> & Lt; FrameLayout Android: id = "@ android: id / tabcontent" android: layout_width = "fill_parent" android: layout_height = "fill_parent" /> & Lt; / LinearLayout & gt;
After doing some very bad workarounds, end In thought through a very simple solution from child activity, I said:
secure void updateParentText () {MyTabActivity parent = (MyTabActivity) this.getParent (); TextView TV = (TextView) parent.findViewById (R.id.textToUpdate); Tv.setText ("New text here"); }
Comments
Post a Comment