android - Changing a textview text dynamically when it is displayed in a tabhost -
firstly, im new android have years of various other programming experience on unix, windows,but not java or android. im wanting display tab 3 tabs, each having different layout file (which works). im working on displaying "blank" template , data retrieved xml file once user points setting 1 (i.e. via shared preferences).
my problem function populatexmlcharacter never called (using breakpoints). tab activity displays "", strig string.xml. putting breakpoint in oncreate function never gets called either. ive tried using call populatexmlcharacter in onresume, never gets called.
im thinking because of call tab:
resources res = getresources(); // resource object drawables tabhost tabhost = gettabhost(); // activity tabhost tabhost.tabspec spec; // resusable tabspec each tab // , same tabs spec = tabhost.newtabspec("description").setindicator("description", res.getdrawable(r.drawable.android)).setcontent(r.layout.tab_harp_description); tabhost.addtab(spec);
should using intent? thought layout created in seperate function (in case harpcsdescription.java , allows activity inserted tabhost?
other functions: public class harpcsdescription extends activity {
public void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview (r.layout.tab_harp_description); } //@override protected void onresume() { // add data template populatexmlcharacter(); } public void populatexmlcharacter() {
ive tried using intents in following manner crashes before breakpoints reached.
http://developer.android.com/resources/tutorials/views/hello-tabwidget.html
can 1 please guide me should doing create activity data retrieved after tab created?
i think need intent. attach activity tab, write following in tab host:
intent intent = new intent(this, myactivity.class);
and in tab spec write:
tabspec = tabhost.newtabspec("name").setindicator(this.getstring(r.string.name)).setcontent(intent)
then in myactivity class, can specify layout , load xml data populate tab in oncreate()
method. can use different activity each tab.
Comments
Post a Comment