开发者

Android TabActivity instance in ViewGroup's chaild Activity

开发者 https://www.devze.com 2023-03-01 22:33 出处:网络
i have TabHost app with Three Activities,in first tab i created a viewGroup.every thing working fine my proble开发者_如何学JAVAm is i want to get TabActivity instance from the view group\'s chaild Act

i have TabHost app with Three Activities,in first tab i created a viewGroup.every thing working fine my proble开发者_如何学JAVAm is i want to get TabActivity instance from the view group's chaild Activity How can i get this... i am trying like this in View group's child activity

Tab_Activity TabObj = (Tab_Activity)getParent();
abObj.someMethod();

i got Class Cast Exception,i think i am getting View group Activity instance, i want to get TabActivity instance,please help me if any one knows answer

 Tab_Activity TabObj = (Tab_Activity)getParent().getParent();

treid like this also... Thanx in Advance


I just tested it: if your TabActivity properly extends the standard android.app.TabActivity then Tab_Activity TabObj = (Tab_Activity)getParent(); should work as designed.

EDIT: AH. You want to do something like this:

Tab_Activity TabObj = (Tab_Activity)((ChildActivity)getContext()).getParent();

from inside the ViewGroup.

0

精彩评论

暂无评论...
验证码 换一张
取 消