android - TabHost: What if I need to handle onOptionsItemSelected each in separate Tab/Activity -


i need have tabhost consisting of 2 tabs each tab represented separate activity. each activity has own data fields , methods operate on them. want each tab have own menu , menu need onoptionsitemselected() method part of class make able invoke methods of class.

what best approach implement this?

i've started menu definition in class represents tabhost, faced problem don't have access methods of activities. decided make methods of activities static have access them need define fields of these activities static doesn't seem solution me.

update:


it became easier thought. in onoptionsitemselected() can current activity of opened tab.

secondactivity sa = (secondactivity)this.getcurrentactivity() sa.mypublicmethod(); 

this depends on sort of functionality implementing. have each activity implement interface instance methods need , have tabhost contain reference current activity of type interface. if this, make sure update reference each time switch activity.


Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -