java - Android setting action bar from child intent -
excuse me, wanted know. possible set action bar child intent
?
in case, main activity sherlockactivity
, it's using tab
host. i'm adding tabspec intent using sherlockactivity too. , want set action bar tabspec's intent.
if possible do, may know how? because makes application meet error.
08-16 10:30:00.470: e/androidruntime(16137): caused by: java.lang.runtimeexception: unable start activity componentinfo{}: java.lang.nullpointerexception
this main activity :
public class mainactivity extends sherlockactivity {
private localactivitymanager lam; private textview tv; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.main_layout); lam = new localactivitymanager(this, false); lam.dispatchcreate(savedinstancestate); getsupportactionbar().setdisplayoptions(actionbar.display_show_custom); getsupportactionbar().setcustomview(r.layout.header); view v = getsupportactionbar().getcustomview(); tv = (textview) v.findviewbyid(r.id.headertitle); tv.settypeface(typeface.createfromasset(alumniapplication.getcontext().getassets(), "fonts/llnitro_.ttf")); tv.settext("title"); settab(); } private void settab(){ tabhost tabhost = (tabhost) findviewbyid(r.id.main_tabhost); tabhost.setup(lam); tabspec com = tabhost.newtabspec("community"); com.setindicator(gettabindicator(r.drawable.com_tab)); com.setcontent(new intent(alumniapplication.getcontext(), communityactivity.class)); tabhost.addtab(com); } private view gettabindicator(int srcid){ view v = layoutinflater.from(alumniapplication.getcontext()).inflate(r.layout.tab_image_layout, null); imageview iv = (imageview) v.findviewbyid(r.id.tab_image); iv.setimageresource(srcid); return v; }
}
and wanted set the action bar child intent
public class communityactivity extends sherlockactivity {
private localactivitymanager lam; @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.tab_above_layout); }
}
but when that, gone error.
if want call method of activity (which hosting fragment) out of child-fragment, need refernece hosting activity. getactivity()
can connection. can call methods of activity inside fragment.
for example:
getactivity().settitle(r.string.my_actionbar_title);
Comments
Post a Comment